public void Repository_GetWeekMetrics() { var options = CreateNewContextOptions(); using (var context = new HighFiveContext(_config, options)) { var repo = new HighFiveRepository(context, _repoLogger); var corpVal1 = new CorporateValue { Name = "Corporate Value1" }; var corpVal2 = new CorporateValue { Name = "Corporate Value2" }; var corpVal3 = new CorporateValue { Name = "Corporate Value3" }; ICollection <CorporateValue> corpVals = new List <CorporateValue>(); corpVals.Add(corpVal1); corpVals.Add(corpVal2); corpVals.Add(corpVal3); repo.AddCorporateValue(corpVal1); repo.AddCorporateValue(corpVal2); repo.AddCorporateValue(corpVal3); repo.SaveChanges(); Organization org = new Organization { Name = "TestOrg", Values = corpVals }; repo.AddOrganization(org); //DateCreated will be within a week since it is set to now repo.AddRecognition(new Recognition { Value = repo.GetCorporateValueByName("Corporate Value1"), Organization = org, Points = 1 }); repo.AddRecognition(new Recognition { Value = repo.GetCorporateValueByName("Corporate Value1"), Organization = org, Points = 1 }); repo.AddRecognition(new Recognition { Value = repo.GetCorporateValueByName("Corporate Value2"), Organization = org, Points = 3 }); repo.AddRecognition(new Recognition { Value = repo.GetCorporateValueByName("Corporate Value3"), Organization = org, Points = 5 }); repo.SaveChanges(); var weekMetrics = repo.GetMetrics(org.Name, 7); weekMetrics.ToList().Count.Should().Equals(3); var met1 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value1"); met1.Points.Should().Equals(2); var met2 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value2"); met1.Points.Should().Equals(2); var met3 = weekMetrics.FirstOrDefault(m => m.CorporateValue == "Corporate Value3"); met1.Points.Should().Equals(2); } }
public void Repository_AddCorporateValue() { var options = CreateNewContextOptions(); using (var context = new HighFiveContext(_config, options)) { var repo = new HighFiveRepository(context, _repoLogger); repo.AddCorporateValue(new CorporateValue { Name = "Corporate Value1" }); } }