I saw several questions about people who asked to criticize their unit tests. It seems to me that they do not close, so I would like to do the same.
I got enraged by these tests, which I think have become more readable using dynamic , but I was wondering if anyone from the SO community has anything to add.
I know that the use of dynamics for some reason is very controversial and for some reason starts religious wars among C # developers. I really hope to avoid this; I'm just trying to write some good tests to help me do my job :)
[TestMethod] public void TestAllocation() { SearchView.StubPropertyNumValueThenSetUpSearchView<WellDetail>("TX", Property.WorkingInterestTaxSubtypeId); Presenter.SetUpPhaseAndFmvValues(Phase.PhaseIdForForRenderAppraiser, 1000); AddTheseItems( new { PropNum = "pn1", CAN = "can1", MostRecentFmv = 10 }, new { PropNum = "pn1", CAN = "can1", MostRecentFmv = 10 }, new { PropNum = "pn1", CAN = "can1", MostRecentFmv = 10 }, new { PropNum = "pn1", CAN = "can1", MostRecentFmv = 10 }, new { PropNum = "pn1", CAN = "can2", MostRecentFmv = 40 }, new { PropNum = "pn1", CAN = "can2", MostRecentFmv = 40 }, new { PropNum = "pn1", CAN = "can2", MostRecentFmv = 40 }, new { PropNum = "pn2", CAN = "can1", MostRecentFmv = 50 }, new { PropNum = "pn2", CAN = "can1", MostRecentFmv = 50 }); Presenter.Process(SearchView, ItemsToProcess); AssertTheseItemsExist( new { NumberOfTimes = 4, PropNum = "pn1", CAN = "can1", FmvCalculated = 100 }, new { NumberOfTimes = 3, PropNum = "pn1", CAN = "can2", FmvCalculated = 400 }, new { NumberOfTimes = 2, PropNum = "pn2", CAN = "can1", FmvCalculated = 500 }); } private void AddTheseItems(params dynamic[] MassUpdateDtos) { foreach(dynamic item in MassUpdateDtos) ItemsToProcess.Add(new MassFMVUpdateDTO(new WellDetail() { PropertyNum = item.PropNum, CountyAccountNum = item.CAN }, new FMVHistory(), 0, item.MostRecentFmv)); } private void AssertTheseItemsExist(params dynamic[] uniqueTargets) { foreach (dynamic target in uniqueTargets) Assert.AreEqual(target.NumberOfTimes, ItemsToProcess.Count(f => f.PropertyNum == target.PropNum && f.CountyAccountNum == target.CAN && f.FMV == target.FmvCalculated)); }