/// <summary> /// Creates a Helper for BudgetClassManager to help in the test's Arrange and Assert sections /// </summary> public BudgetClassManagerHelper( BudgetClassManager classBudgetClassManager, BudgetDbSetupHelper budgetDbSetupHelper) { BudgetClassManager = classBudgetClassManager; BudgetDbSetupHelper = budgetDbSetupHelper; BudgetClassMapper = new BudgetClassDataMapper(); }
/// <summary> /// Asserts that entities equivalent to the supplied input data classes exist /// </summary> /// <param name="dataSet">Data for the entities to be searched for</param> public void AssertEntitiesExist(params BudgetClassData[] dataSet) { using (BudgetDbContext dbContext = BudgetDbSetupHelper.GetDbContext()) { var manager = new BudgetClassManager(dbContext); var mapper = new BudgetClassDataMapper(); foreach (BudgetClassData data in dataSet) { BudgetClass entity = manager.SingleOrDefault(e => e.Name == data.Name); entity.Should().NotBeNull(@"because BudgetClass ""{0}"" MUST EXIST!", data.Name); BudgetClassData entityData = mapper.CreateData(entity); entityData.ShouldBeEquivalentTo(data); } } }