public async Task TestDeleteMinuteNull() { Mock <IMinuteRepository> mock = new Mock <IMinuteRepository>(); MinuteController controller = new MinuteController(mock.Object); Minute minute = null; ArgumentNullException exception = await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => controller.DeleteMinute(minute)); Assert.AreEqual(exception.ParamName, nameof(minute)); }
public async Task TestGetById() { Mock <IMinuteRepository> mock = new Mock <IMinuteRepository>(); MinuteController controller = new MinuteController(mock.Object); mock.Setup(mock => mock.GetById(It.IsAny <Guid>())).ReturnsAsync(new Minute()); Minute minute = await controller.GetById(Guid.NewGuid()); Assert.IsNotNull(minute); }
public async Task TestDeleteById() { Mock <IMinuteRepository> mock = new Mock <IMinuteRepository>(); MinuteController controller = new MinuteController(mock.Object); mock.Setup(t => t.Delete(It.IsAny <int>())).Verifiable(); await controller.DeleteMinuteByID(1); mock.VerifyAll(); }
public async Task TestDeleteMinute() { Mock <IMinuteRepository> mock = new Mock <IMinuteRepository>(); MinuteController controller = new MinuteController(mock.Object); Minute minute = new Minute() { Id = new Guid() }; mock.Setup(t => t.Delete(It.IsAny <Minute>())).Verifiable(); await controller.DeleteMinute(minute); mock.VerifyAll(); }
public async Task TestGetAllMinute() { Minute[] minute = { new Minute { Id = new Guid() }, new Minute{ Id = new Guid() } }; Mock <IMinuteRepository> mock = new Mock <IMinuteRepository>(); MinuteController controller = new MinuteController(mock.Object); mock.Setup(t => t.Get( It.IsAny <Expression <Func <Minute, bool> > >(), It.IsAny <Func <IQueryable <Minute>, IOrderedQueryable <Minute> > >(), It.IsAny <string>())).ReturnsAsync(minute); IEnumerable <Minute> found = await controller.GetAllMinute(); Assert.AreEqual(2, found.Count()); }