public void Initialize()
 {
     //Arrange
     Context = new TestDbContext();
     var uow = new UnitofWork(Context);
     Controller = new UnitofWorkPatternController(uow);
 }
 public void Initialize()
 {
     //Arrange
     var fakeUnits = new FakeUnits();
     var unitRepo = new FakeUnitRepository(fakeUnits.MyUnits);
     var uow = new UnitofWork { UnitRepository = unitRepo };
      Controller = new UnitofWorkPatternController(uow);
 }
        public void IndexWithMocking()
        {
            //arrange
            var controller = new UnitofWorkPatternController(MockUnitofWork.Object);

            // act
            var actual = controller.Index();

            // assert
            var viewResult = actual as ViewResult;
            if (viewResult == null) return;
            var data = viewResult.ViewData.Model as IList<Unit>;
            if (data != null) Assert.AreEqual(2, data.Count);
        }
        public void Index()
        {
            //Arrange//
            UnitRepo = new DummyRentalRepositoryTest(_fakeUnits.MyUnits);

            // Let us now create the Unit of work with our dummy repository
            Uow = new UnitofWork {UnitRepository = UnitRepo};

            // Now lets create the unitsController object to test and pass our unit of work
            Controller = new UnitofWorkPatternController(Uow);

            // act
            var actual = Controller.Index();

            // assert
            var viewResult = actual as ViewResult;
            if (viewResult == null) return;
            var data = viewResult.ViewData.Model as IList<Unit>;
            if (data != null) Assert.AreEqual(1, data.Count);
        }
        public void IndexWithMocking()
        {
            // Arrange
            //Creating a mock Object
            //Pass the mock to the SUT
            var repoMock = new Mock<IGenericRepository<Unit>>();
            repoMock.Setup(x => x.All).Returns(_fakeUnits.MyUnits.AsQueryable());

            var unitofWork = new UnitofWork{ UnitRepository = repoMock.Object};

              //  var uowMock = new Mock<UnitofWork>(repoMock.Object);
            Controller = new UnitofWorkPatternController(unitofWork);

            //ACT
                //Execute the SUT
            var actual = Controller.Index();

            //Assert
                //Verify SUT's interaction with the mock object
            var viewResult = actual as ViewResult;
            if (viewResult == null) return;
            var data = viewResult.ViewData.Model as IList<Unit>;
            if (data != null) Assert.AreEqual(1, data.Count );
        }
 public void CleanUp()
 {
     Context = null;
     Controller = null;
 }
 public void CleanUp()
 {
     FakeUnits = null;
     Controller = null;
 }