Skip to content

Commit

Permalink
Merge pull request #702 from aydjay/essenceOfCorruption
Browse files Browse the repository at this point in the history
Ensured that essence of corruption makes it to the forum template
  • Loading branch information
Stickymaddness authored Jun 29, 2017
2 parents 3659ab1 + d815340 commit 2a1c114
Show file tree
Hide file tree
Showing 9 changed files with 1,748 additions and 15 deletions.
10 changes: 10 additions & 0 deletions POEApi.Model.Tests/Files.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions POEApi.Model.Tests/Files.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@
<data name="SampleStashWithRelic" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>testdata\samplestashwithrelic.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="SampleStashWithRemnantOfCorruption" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>testdata\samplestashwithremnantofcorruption.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
50 changes: 50 additions & 0 deletions POEApi.Model.Tests/IFilterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using POEApi.Transport;
using Procurement.ViewModel.Filters;
using Procurement.ViewModel.Filters.ForumExport;
using static POEApi.Model.Tests.UnitTestHelper;

namespace POEApi.Model.Tests
{
[TestClass]
public class IFilterTests
{
private Mock<ITransport> _mockTransport;
private POEModel _model;
private IFilter filter;

[TestInitialize]
public void TestSetup()
{
_mockTransport = new Mock<ITransport>();
_model = new POEModel { Transport = _mockTransport.Object };
}

[TestMethod]
public void AreEssencesApplicable()
{
string fakeStashInfo = Encoding.UTF8.GetString(Files.SampleStashWithRemnantOfCorruption);
filter = new EssenceFilter();

using (var stream = GenerateStreamFromString(fakeStashInfo))
{
_mockTransport.Setup(m => m.GetStash(0, "", "", false)).Returns(stream);

var stash = _model.GetStash(0, "", "");

Assert.IsNotNull(stash);

var essences = stash.GetItemsByTab(6);

Assert.IsTrue(essences.All(x => x is Essence));

//All the items, which are essences in the first place, should make it into the forum template
Assert.IsTrue(essences.TrueForAll(filter.Applicable));
}
}
}
}
7 changes: 7 additions & 0 deletions POEApi.Model.Tests/POEApi.Model.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
</Compile>
<Compile Include="PoeModelTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="IFilterTests.cs" />
<Compile Include="UnitTestHelper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand All @@ -76,6 +78,7 @@
<None Include="TestData\SampleStash.json" />
<None Include="TestData\SampleStashWithEssences.json" />
<None Include="TestData\SampleStashWithRelic.json" />
<None Include="TestData\SampleStashWithRemnantOfCorruption.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\POEApi.Model\POEApi.Model.csproj">
Expand All @@ -86,6 +89,10 @@
<Project>{5933C062-45EA-4BC3-9AE9-0D6CFC26D505}</Project>
<Name>POEApi.Transport</Name>
</ProjectReference>
<ProjectReference Include="..\Procurement\Procurement.csproj">
<Project>{9369113D-A68F-4FE9-B301-D00C5176666A}</Project>
<Name>Procurement</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Files.resx">
Expand Down
15 changes: 2 additions & 13 deletions POEApi.Model.Tests/PoeModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using POEApi.Transport;
using static POEApi.Model.Tests.UnitTestHelper;

namespace POEApi.Model.Tests
{
Expand Down Expand Up @@ -126,15 +125,5 @@ public void GetAccountNameTest()
Assert.AreEqual(account, "fakeAccountName");
}
}

public Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
}
Loading

0 comments on commit 2a1c114

Please sign in to comment.