public void Stratabase_PropertyReference() { TestDataContainer tdc = new TestDataContainer { StrValue = "TDC", Foo = new TestData { Name = "TDC: Child", Value = 4 } }; Stratabase sb = new Stratabase(2); sb.SetBaselineFromPropertiesOf(tdc); var strValueAccess = sb.GeneratePropertyAccess <string>(tdc.Id, nameof(TestDataContainer.StrValue)); var fooRef = sb.GeneratePropertyAccess <Guid>(tdc.Id, nameof(TestDataContainer.Foo)); StrataPropertyAdapter <Guid, StrataTestData> fooAdapter = new StrataPropertyAdapter <Guid, StrataTestData>(fooRef, (_sb, _id) => new StrataTestData(_sb, _id)); var foo = fooAdapter.Value; Assert.AreEqual("TDC", strValueAccess.GetValue()); Assert.AreEqual("TDC: Child", foo.Name); Assert.AreEqual(4, foo.Value); }
public Tuple <List <DtDeviceFile>, List <ArchiveFile> > GetExpected(string methodName) { var instance = new TestDataContainer(); MethodInfo mi = typeof(TestDataContainer).GetMethod(methodName); return((Tuple <List <DtDeviceFile>, List <ArchiveFile> >)mi.Invoke(instance, null)); }
public void ShouldReturnFirstQuestion() { //arrange var context = TestDbContextCreator.CreateInMemory(nameof(ShouldReturnFirstQuestion)); var questions = TestDataContainer.GetQuestionEntities(); context.Questions.AddRange(questions); context.SaveChanges(); var sut = new QuestionsService(context); var expected = new Question { Id = 1, Text = "Do I want a doughnut?", PositiveAnswerQuestionId = 2, NegativeAnswerQuestionId = 3 }; //act var actual = sut.GetFirstQuestion(); //assert actual.Should().BeEquivalentTo(expected); }
public void Should_Dropt_Quality_To_Zero_For_Backstage_After_The_Concert() { var items = TestDataContainer.GetListWithAgedBackstagePasses(); _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose, 21); Assert.AreEqual(0, items.First().Quality); }
public void Should_Increase_Quality_For_Backstage_By_Three_If_Days_Are_In_Range_Zero_To_Five() { var items = TestDataContainer.GetListWithAgedBackstagePasses(); _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose, 16); Assert.AreEqual(33, items.First().Quality); }
public void Should_Degrade_Qulatity_Twice_As_Fast_After_Passed_Sell_By_Date_For_Aged_Brie() { var items = TestDataContainer.GetListWithAgedBrieOnly(); _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose, 4); Assert.AreEqual(15, items.First().Quality); }
public void Should_Not_Change_Quality_For_Sulfuras() { var items = TestDataContainer.GetListWithSulfurasOnly(); var startedQuality = items.First().Quality; _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose); Assert.AreEqual(startedQuality, items.First().Quality); }
public void Should_Decrease_Quality_By_Four_Each_Day_If_Sell_In_Less_Than_Zero() { var items = TestDataContainer.GetListWithConjuredOnlyWithZeroSellIn(); var expectedQuality = items.First().Quality - 4; _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose, 1); Assert.AreEqual(expectedQuality, items.First().Quality); }
public void Should_Decrease_Quality_For_Not_Specified_Item_If_SellIn_Less_Than_Zero() { var items = TestDataContainer.GetListWithoutSpecifiedItemsWithZeroSellIn(); _gildedRose = new GildedRose(items); var expectedQuality = items.First().Quality - 2; UpdateQuality(_gildedRose, 1); Assert.AreEqual(expectedQuality, items.First().Quality); }
public void Should_Decrease_Quality_For_Not_Specified_Item() { var items = TestDataContainer.GetListWithoutSpecifiedItems(); var startedQuality = items.First().Quality; _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose, 1); Assert.AreEqual(startedQuality - 1, items.First().Quality); }
private void RunTestDataGeneration(CancellationToken ct) { Thread.Sleep(50000); var testDataContainer = new TestDataContainer(_unityContainer); var container = testDataContainer.Value; _result = container.Resolve <ITestData>().Value; if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } }
public void Should_Keep_Quality_In_Range_Zero_To_Fifty() { var items = TestDataContainer.GetDefaultItemList(); _gildedRose = new GildedRose(items); UpdateQuality(_gildedRose); foreach (var item in items) { Assert.IsTrue(item.Quality >= 0 && item.Quality <= 50); } }
public void Should_Increase_Quality_For_Backstage_Passes_The_Older_It_Gets() { var items = TestDataContainer.GetListWithAgedBackstagePasses(); _gildedRose = new GildedRose(items); _gildedRose.UpdateQuality(); var firstDayQuality = items.First().Quality; _gildedRose.UpdateQuality(); var secondDayQuality = items.First().Quality; Assert.IsTrue(secondDayQuality > firstDayQuality); }
public void Search_WithValidBindings_ResultsAreWrittenToDestinationData() { var container = new TestDataContainer { ValidSourceData = Generate(100), ValidDestinationData = new List <TestData>() }; m_PropertyElement.SetTarget(container); m_SearchElement.RegisterSearchQueryHandler(m_PropertyElement, TestDataContainer.ValidSourceDataPath, TestDataContainer.ValidDestinationDataPath); m_SearchElement.AddSearchDataProperty(new PropertyPath("Name")); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(0)); m_SearchElement.Search(""); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(container.ValidSourceData.Length)); m_SearchElement.Search("Mesh"); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(25)); }
public void Search_WithCollectionSearchData_ResultsAreWrittenToDestinationData() { var container = new TestDataContainer { ValidSourceData = Generate(100), ValidDestinationData = new List <TestData>() }; container.ValidSourceData[0].StringArray = new[] { "one", "two", "three", "four" }; container.ValidSourceData[1].StringArray = new[] { "two", "three", "four" }; container.ValidSourceData[2].StringArray = new[] { "three", "four" }; container.ValidSourceData[3].StringArray = new[] { "four" }; m_PropertyElement.SetTarget(container); m_SearchElement.RegisterSearchQueryHandler(m_PropertyElement, TestDataContainer.ValidSourceDataPath, TestDataContainer.ValidDestinationDataPath); m_SearchElement.AddSearchDataProperty(new PropertyPath("StringArray")); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(0)); m_SearchElement.Search("two"); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(2)); m_SearchElement.Search("three"); Assert.That(container.ValidDestinationData.Count, Is.EqualTo(3)); }
public void EndToEndCherryPickerTest() { ITestDataContainer testDataContainer = new TestDataContainer(); testDataContainer .For <Invoice>(x => x .Default(i => i.Recipient).ToAutoBuild()) .For <Recipient>(x => x .Default(r => r.CustomerName).To("Sherlock Holmes") .Default(r => r.Address).ToAutoBuild()) .For <Address>(x => x .Default(a => a.FirstLine).To("221b Baker Street") .Default(a => a.City).To("London") .Default(a => a.PostCode).ToAutoBuild()) .For <PostCode>(x => x .Default(pc => pc.OutwardCode).To("NW1") .Default(pc => pc.InwardCode).To("3RX")); var invoice = testDataContainer.Build <Invoice>(x => x .Set(i => i.InvoiceLines).To( new List <InvoiceLine> { testDataContainer.Build <InvoiceLine>(y => y .Set(il => il.Product).To("Deerstalker Hat") .Set(il => il.Cost).To( testDataContainer.Build <PoundsShillingsPence>(z => z .Set(psp => psp.Pounds).To(0) .Set(psp => psp.Shillings).To(3) .Set(psp => psp.Pence).To(10)))), testDataContainer.Build <InvoiceLine>(y => y .Set(il => il.Product).To("Tweed Cape") .Set(il => il.Cost).To( testDataContainer.Build <PoundsShillingsPence>(z => z .Set(psp => psp.Pounds).To(0) .Set(psp => psp.Shillings).To(4) .Set(psp => psp.Pence).To(12)))), })); }
public void RoundTripArrayContainer() { var expected = new TestDataContainer { Array2D = new Microsoft.Xna.Framework.Rectangle[3, 2], Array3D = new Microsoft.Xna.Framework.Rectangle[3, 4, 2] }; for (int y = 0; y < expected.Array2D.GetLength(1); y++) { for (int x = 0; x < expected.Array2D.GetLength(0); x++) { expected.Array2D[x, y] = new Microsoft.Xna.Framework.Rectangle(x, y, -x, -y); } } for (int z = 0; z < expected.Array3D.GetLength(2); z++) { for (int y = 0; y < expected.Array3D.GetLength(1); y++) { for (int x = 0; x < expected.Array3D.GetLength(0); x++) { expected.Array3D[x, y, z] = new Microsoft.Xna.Framework.Rectangle(x, y, z, -z); } } } CompileAndLoadAssets(expected.DeepClone(), result => { Assert.IsNotNull(result.Array3D); Assert.IsInstanceOf <Microsoft.Xna.Framework.Rectangle[, , ]>(result.Array3D); Assert.AreEqual(result.Array3D.Rank, 3); for (int i = 0; i < result.Array3D.Rank; i++) { Assert.AreEqual(expected.Array3D.GetLength(i), result.Array3D.GetLength(i)); } for (int z = 0; z < expected.Array3D.GetLength(2); z++) { for (int y = 0; y < expected.Array3D.GetLength(1); y++) { for (int x = 0; x < expected.Array3D.GetLength(0); x++) { Assert.AreEqual(expected.Array3D[x, y, z], result.Array3D[x, y, z]); } } } Assert.IsNotNull(result.Array2D); Assert.IsInstanceOf <Microsoft.Xna.Framework.Rectangle[, ]>(result.Array2D); Assert.AreEqual(result.Array2D.Rank, 2); for (int i = 0; i < result.Array2D.Rank; i++) { Assert.AreEqual(expected.Array2D.GetLength(i), result.Array2D.GetLength(i)); } for (int y = 0; y < expected.Array2D.GetLength(1); y++) { for (int x = 0; x < expected.Array2D.GetLength(0); x++) { Assert.AreEqual(expected.Array2D[x, y], result.Array2D[x, y]); } } }); }
private void Start() { dc = GetComponentInParent <TestDataContainer>(); states = GetComponentInParent <StateManager>(); stringState = GetComponent <TestStringState>(); }