Example #1
0
        public async Task TestDeleteDateMobileNull()
        {
            Mock <IDateRepository> mock       = new Mock <IDateRepository>();
            DateMobileController   controller = new DateMobileController(mock.Object);

            DateMobile date = null;

            ArgumentNullException exception = await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => controller.DeleteDate(date));

            Assert.AreEqual(exception.ParamName, nameof(date));
        }
Example #2
0
        public async Task TestGetById()
        {
            Mock <IDateRepository> mock       = new Mock <IDateRepository>();
            DateMobileController   controller = new DateMobileController(mock.Object);

            mock.Setup(mock => mock.GetById(It.IsAny <Guid>())).ReturnsAsync(new DateMobile());

            DateMobile date = await controller.GetById(Guid.NewGuid());

            Assert.IsNotNull(date);
        }
Example #3
0
        public async Task TestDeleteById()
        {
            Mock <IDateRepository> mock       = new Mock <IDateRepository>();
            DateMobileController   controller = new DateMobileController(mock.Object);

            mock.Setup(t => t.Delete(It.IsAny <int>())).Verifiable();

            await controller.DeleteDateByID(1);

            mock.VerifyAll();
        }
Example #4
0
        public async Task TestDeleteDateMobile()
        {
            Mock <IDateRepository> mock       = new Mock <IDateRepository>();
            DateMobileController   controller = new DateMobileController(mock.Object);

            DateMobile date = new DateMobile()
            {
                Id = new Guid()
            };

            mock.Setup(t => t.Delete(It.IsAny <DateMobile>())).Verifiable();

            await controller.DeleteDate(date);

            mock.VerifyAll();
        }
Example #5
0
        public async Task TestGetAllDate()
        {
            DateMobile[] date = { new DateMobile {
                                      Id = new Guid()
                                  }, new DateMobile{
                                      Id = new Guid()
                                  } };

            Mock <IDateRepository> mock       = new Mock <IDateRepository>();
            DateMobileController   controller = new DateMobileController(mock.Object);;

            mock.Setup(t => t.Get(
                           It.IsAny <Expression <Func <DateMobile, bool> > >(),
                           It.IsAny <Func <IQueryable <DateMobile>, IOrderedQueryable <DateMobile> > >(),
                           It.IsAny <string>())).ReturnsAsync(date);

            IEnumerable <DateMobile> found = await controller.GetAllDate();

            Assert.AreEqual(2, found.Count());
        }