public void AddAgentsInSmsQueue_NewUser_FirstSms() { // arrange List <SMSSendingQueue> data = new List <SMSSendingQueue>(); _fakeDbContext.Setup(x => x.SMSSendingQueue).Returns(_fakeDbContext.Object.SmsSendingQueueMock.Object); _fakeDbContext.Object.SmsSendingQueueMock.SetMockQueryable(data.AsQueryable()); _fakeDbContext.Object.SmsSendingQueueMock.Setup(m => m.Add(It.IsAny <SMSSendingQueue>())) .Callback(() => { data.AddRange(agents.Select(x => new SMSSendingQueue { UserId = x.UserId, TimeSecondSmsSent = DateTime.Now.TimeOfDay })); }); BotStorageRepo repo = new BotStorageRepo(_fakeDbContext.Object); // act TimeSpan time = repo.AddAgentsInSmsQueue(agents); // assert _fakeDbContext.Object.SmsSendingQueueMock.Verify(x => x.Add(It.IsAny <SMSSendingQueue>()), Times.AtLeastOnce()); Assert.AreEqual(default(Guid), _fakeDbContext.Object.SMSSendingQueue.First().UserId); Assert.AreNotEqual(default(TimeSpan), _fakeDbContext.Object.SMSSendingQueue.First().TimeSecondSmsSent); }
public void GetUserDailyStat_Test() { // arrange _fakeDbContext.Setup(x => x.SMSUserDayStatistic).Returns(_fakeDbContext.Object.SmsUserDayStatisticMock.Object); _fakeDbContext.Object.SmsUserDayStatisticMock.SetMockQueryable(stat.AsQueryable()); BotStorageRepo repo = new BotStorageRepo(_fakeDbContext.Object); byte expectedCount = stat.Where(x => x.Date == DateTime.UtcNow.Date).First().MessageCount; // act Dictionary <Guid, byte> res = repo.GetUsersDailyStatistic(new Guid[] { new Guid("fb33939c-179d-4049-8a3c-30bbd8538304") }); // assert Assert.AreEqual(expectedCount, _fakeDbContext.Object.SMSUserDayStatistic.First().MessageCount); }