public void Test_SaveDateCase(string[] carrierInfos, string[] dateStrings, int count) { SaveTimeStatsService <FakeCarrierTimeStat, FakeCarrierTimeStat> service = new FakeSaveTimeDateStatsService(repository.Object); List <FakeCarrierTimeStat> infos = carrierInfos.Select((t, i) => new FakeCarrierTimeStat { Carrier = t, StatTime = DateTime.Parse(dateStrings[i]) }).ToList(); int resultCount = service.Save(infos); Assert.AreEqual(resultCount, count); for (int i = 0; i < resultCount; i++) { FakeCarrierTimeStat stat = repository.Object.Stats.ElementAt(i); Assert.AreEqual(stat.StatTime, DateTime.Parse(dateStrings[i])); Assert.AreEqual(stat.Carrier, carrierInfos[i]); } }
public void Test_SaveDateConsideredCase(string[] carrierInfos, string[] dateStrings, string[] existedDates, int count) { repository.SetupGet(x => x.Stats).Returns(existedDates.Select(x => new FakeCarrierTimeStat { Carrier = "c", StatTime = DateTime.Parse(x) }).AsQueryable()); SaveTimeStatsService <FakeCarrierTimeStat, FakeCarrierTimeStat> service = new FakeSaveTimeDateStatsService(repository.Object); List <FakeCarrierTimeStat> infos = carrierInfos.Select((t, i) => new FakeCarrierTimeStat { Carrier = t, StatTime = DateTime.Parse(dateStrings[i]) }).ToList(); int resultCount = service.Save(infos); Assert.AreEqual(resultCount, count, existedDates[0]); }