Пример #1
0
        public async void Test_Delete_Visitor()
        {
            //Arrange
            var db      = MockDb.CreateMockDb();
            var c       = new VisitorsController(db);
            var visitor = new Visitor {
                FirstName = "Alex", LastName = "Coa", PhoneNumber = "6476666888", ParkingId = 5, TimeOfEntry = System.DateTime.Today, TimeOfExit = System.DateTime.Today
            };
            //Act
            var r = await c.Delete(1);

            //Assert
            var result = Assert.IsType <ViewResult>(r);
            var model  = Assert.IsAssignableFrom <Visitor>(result.Model);

            Assert.Equal(visitor, model);
        }
        public async Task VisitorsController_Delete_Test()
        {
            bool called            = false;
            var  visitorRepository = new Data.Repositories.Fakes.StubIVisitorRepository();

            var visitor = new Visitor()
            {
                VisitorId = 1,
            };

            visitorRepository.DeleteAsyncInt32 = (id) =>
            {
                Assert.IsTrue(id == visitor.VisitorId);
                called = true;
                return(Task.FromResult(string.Empty));
            };

            var target = new VisitorsController(visitorRepository);
            await target.Delete(visitor.VisitorId);

            Assert.IsTrue(called);
        }