Esempio n. 1
0
        public void ItemsCrud_Index_Test()
        {
            // arrange
            List <Item> items = new List <Item>();
            Item        item  = new Item {
                Name = ITEM1_NAME
            };
            Item item2 = new Item {
                Name = ITEM2_NAME
            };

            items.Add(item);
            items.Add(item2);

            FakeUnitOfWork      fakeUnit = new FakeUnitOfWork(null, items);
            ItemsCrudController target   = new ItemsCrudController(fakeUnit);

            // act
            var view = (ViewResult)target.Index();

            // assert
            var model = (List <Item>)view.Model;

            Assert.AreEqual(ITEM1_NAME, model[0].Name);
            Assert.AreEqual(ITEM2_NAME, model[1].Name);
        }
        public async Task persistence_uow_retreive_bag()
        {
            var bag = new ContextBag();

            bag.Set("test", "test");
            var context = new Moq.Mock <IIncomingLogicalMessageContext>();
            var next    = new Moq.Mock <Func <Task> >();
            var builder = new Moq.Mock <IBuilder>();
            var uow     = new FakeUnitOfWork();

            builder.Setup(x => x.BuildAll <IApplicationUnitOfWork>()).Returns(new IApplicationUnitOfWork[] { uow });
            context.Setup(x => x.MessageId).Returns("1");
            context.Setup(x => x.Message).Returns(new LogicalMessage(new NServiceBus.Unicast.Messages.MessageMetadata(typeof(object)), new object()));
            context.Setup(x => x.Extensions).Returns(bag);
            context.Setup(x => x.Builder).Returns(builder.Object);
            context.Setup(x => x.Headers).Returns(new Dictionary <string, string>());
            context.Setup(x => x.MessageHeaders)
            .Returns(new Dictionary <string, string> {
                [Headers.MessageIntent] = MessageIntentEnum.Send.ToString()
            });
            _persistence.Setup(x => x.Remove("1", uow.GetType())).Returns(Task.FromResult(bag));

            await _uow.Invoke(context.Object, next.Object);

            next.Verify(x => x(), Moq.Times.Once);

            string test;

            Assert.True(uow.Bag.TryGet <string>("test", out test));
            Assert.AreEqual("test", test);

            _persistence.Verify(x => x.Save("1", uow.GetType(), bag), Moq.Times.Once);
            _persistence.Verify(x => x.Clear("1"), Moq.Times.Once);
        }
Esempio n. 3
0
        public CreateUpdateTests()
        {
            _mapper = MyMapperConfiguration.GetConfiguration().CreateMapper();
            var unitOfWork = new FakeUnitOfWork();

            _service = new AirportService(unitOfWork);
        }
        public async Task retries_are_set()
        {
            var bag = new ContextBag();

            bag.Set(Defaults.Retries, 1);
            var context = new Moq.Mock <IIncomingLogicalMessageContext>();
            var next    = new Moq.Mock <Func <Task> >();
            var builder = new Moq.Mock <IBuilder>();
            var uow     = new FakeUnitOfWork();

            builder.Setup(x => x.BuildAll <IApplicationUnitOfWork>()).Returns(new IApplicationUnitOfWork[] { uow });
            context.Setup(x => x.MessageId).Returns("1");
            context.Setup(x => x.Message).Returns(new LogicalMessage(new NServiceBus.Unicast.Messages.MessageMetadata(typeof(object)), new object()));
            context.Setup(x => x.Extensions).Returns(bag);
            context.Setup(x => x.Builder).Returns(builder.Object);
            context.Setup(x => x.Headers).Returns(new Dictionary <string, string>());
            context.Setup(x => x.MessageHeaders)
            .Returns(new Dictionary <string, string> {
                [Headers.MessageIntent] = MessageIntentEnum.Send.ToString()
            });


            await _uow.Invoke(context.Object, next.Object);

            next.Verify(x => x(), Moq.Times.Once);
            Assert.AreEqual(1, uow.Retries);
        }
Esempio n. 5
0
        public void Initialize()
        {
            AutoMapperConfiguration.Configure();
            userModel = new Dictionary <Guid, User>();
            roleModel = new Dictionary <Guid, Role>();
            Guid id1   = new Guid("93297545-6aff-44cf-911c-fc4b5a88b404");
            Guid id2   = new Guid("e4c61d79-dc41-4f9d-8619-05a4f8a6f9a9");
            Guid id3   = new Guid("be77764a-3283-4f9a-b3e6-eb2e65d0b8e8");
            User user1 = new User
            {
                Id        = id1,
                Username  = "******",
                Password  = "******",
                FirstName = "Test",
                LastName  = "Test",
                Email     = "*****@*****.**",
                RoleId    = new Guid("56dc86b4-1229-e411-9417-a41f7255f9b5")
            };
            User user2 = new User
            {
                Id        = id2,
                Username  = "******",
                Password  = "******",
                FirstName = "Test",
                LastName  = "Test",
                Email     = "*****@*****.**",
                RoleId    = new Guid("56dc86b4-1229-e411-9417-a41f7255f9b5")
            };
            User user3 = new User
            {
                Id        = id3,
                Username  = "******",
                Password  = "******",
                FirstName = "Test",
                LastName  = "Test",
                Email     = "*****@*****.**",
                RoleId    = new Guid("56dc86b4-1229-e411-9417-a41f7255f9b5")
            };
            Role role = new Role {
                Name = "repairmen", Id = new Guid("56dc86b4-1229-e411-9417-a41f7255f9b5")
            };

            userModel.Add(id1, user1);
            userModel.Add(id2, user2);
            userModel.Add(id3, user3);
            roleModel.Add(role.Id, role);

            FakeUnitOfWork unitOfWork = new FakeUnitOfWork();

            unitOfWork.Users = userModel;
            unitOfWork.Roles = roleModel;

            controller = new LoginController(unitOfWork)
            {
                Request = new HttpRequestMessage()
                {
                    Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
                }
            };
        }
 public override void EstablishContext()
 {
     base.EstablishContext();
     RepositoryMock = new Mock <IComponentInterfaceRepository>();
     UnitOfWork     = new FakeUnitOfWork();
     Service        = new ComponentInterfaceService(UnitOfWork, RepositoryMock.Object);
 }
Esempio n. 7
0
        public void ItemsCrud_Create_Test()
        {
            // arrange
            List <Item>         items = new List <Item>();
            ItemCreateViewModel item  = new ItemCreateViewModel {
                Name = ITEM1_NAME, Value = 12, Points = 4
            };
            ItemCreateViewModel item2 = new ItemCreateViewModel {
                Name = ITEM2_NAME
            };
            List <Merchant> merchants = new List <Merchant>();

            merchants.Add(new Merchant {
                ID = 1, Name = MERCHANT
            });

            FakeUnitOfWork      fakeUnit = new FakeUnitOfWork(merchants, items);
            ItemsCrudController target   = new ItemsCrudController(fakeUnit);

            // act
            target.Create(item, RARE, MERCHANT, TYPE);
            target.Create(item2, RARE, MERCHANT, TYPE);

            // assert
            Assert.AreEqual(ITEM1_NAME, items[0].Name);
            Assert.AreEqual(ITEM2_NAME, items[1].Name);
            Assert.AreEqual(1, items[0].MerchantID);
        }
        public RepositoryFixture()
        {
            // AutoMapper
            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.CreateMap <Entity <int>, FakeModel>());

            // data mapper
            DataMapper = new FakeDataMapper();

            // database
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <FakeDbContext>().UseInMemoryDatabase($"{nameof(RepositoryFixture)}{Guid.NewGuid():N}");

            UnitOfWork = new FakeUnitOfWork(
                dbContext => new FakeRepository(dbContext),
                dbContextOptionsBuilder.Options,
                "dbo"
                );

            UnitOfWork.FakeEntityRepository.Insert(new FakeEntity());
            UnitOfWork.FakeEntityRepository.Insert(new FakeEntity());
            UnitOfWork.FakeEntityRepository.Insert(new FakeEntity());
            UnitOfWork.FakeEntityRepository.Insert(new FakeEntity());
            UnitOfWork.FakeEntityRepository.Insert(new FakeEntity());
            UnitOfWork.Commit();

            ExistingFakeEntity = UnitOfWork.FakeEntityRepository.GetList().First();
            ExistingFakeModel  = UnitOfWork.FakeEntityRepository.GetList <FakeModel>(DataMapper).First();
        }
        public void TestInitialize()
        {
            FakeUnitOfWork = new FakeUnitOfWork();

            Mapper = new Mapper(new MapperConfiguration(c => c.AddProfile(new MappingProfile())));

            TruckService = new TruckService(FakeUnitOfWork, Mapper);
        }
    public void SaveSucceeds()
    {
        var mockedContext = new Mock <DbContext>();
        var unitOfWork    = new FakeUnitOfWork(mockedContext.Object);

        unitOfWork.Save();
        mockedContext.Verify(context => context.SaveChanges(), Times.Once);
    }
        public TicketCategoryApplicationServiceTests()
        {
            repository = new FakeTicketCategoryRepository();
            domainNotificationHandler = new DomainNotificationHandler();
            serviceBus = new FakeServiceBus();
            unitOfWork = new FakeUnitOfWork();

            appService = new TicketCategoryApplicationService(repository, domainNotificationHandler, unitOfWork, serviceBus);
        }
    public void SaveAsyncSucceeds()
    {
        var mockedContext = new Mock <DbContext>();
        var unitOfWork    = new FakeUnitOfWork(mockedContext.Object);

        var cancellationToken = new CancellationToken();

        unitOfWork.SaveAsync(cancellationToken).Wait(cancellationToken);
        mockedContext.Verify(context => context.SaveChangesAsync(It.IsIn(cancellationToken)), Times.Once);
    }
        public ArticleCategoryApplicationServiceTests()
        {
            fakeUnitOfWork            = new FakeUnitOfWork();
            fakeServiceBus            = new FakeServiceBus();
            fakeDomainBus             = new FakeDomainBus();
            domainNotificationHandler = new DomainNotificationHandler();
            repository = new FakeArticleCategoryRepository();

            applicationService = new ArticleCategoryApplicationService(repository, domainNotificationHandler, fakeUnitOfWork, fakeServiceBus, fakeDomainBus);
        }
Esempio n. 14
0
        public ActivationApplicationServiceTests()
        {
            activationFactory         = new ActivationFactory();
            identityResolver          = new FakeIdentityResolver();
            domainNotificationHandler = new DomainNotificationHandler();
            fakeUnitOfWork            = new FakeUnitOfWork();
            serviceBus           = new FakeServiceBus();
            domainBus            = new FakeDomainServiceBus();
            activationRepository = new FakeActivationRepository();

            service = new ActivationApplicationService(activationRepository, identityResolver, domainNotificationHandler, fakeUnitOfWork, serviceBus, domainBus);
        }
Esempio n. 15
0
        public CompanyApplicationServiceTests()
        {
            repository                = new FakeCompanyRepository();
            locationService           = new LocationService(new FakeCityRepository(), new StateFakeRepository(), new CountryFakeRepository());
            bus                       = new FakeServiceBus();
            uow                       = new FakeUnitOfWork();
            identityResolver          = new FakeIdentityResolver();
            domainNotificationHandler = new DomainNotificationHandler();
            factory                   = new CompanyFactory();

            service = new CompanyApplicationService(repository, factory, locationService, identityResolver, domainNotificationHandler, uow, bus);
        }
        public TicketApplicationServiceTests()
        {
            fakeTicketRepository         = new FakeTicketRepository();
            fakeTicketCategoryRepository = new FakeTicketCategoryRepository();
            domainNotificationHandler    = new DomainNotificationHandler();
            factory          = new TicketFactory();
            fakeServiceBus   = new FakeServiceBus();
            uow              = new FakeUnitOfWork();
            identityResolver = new FakeIdentityResolver();

            applicationService = new TicketApplicationService(fakeTicketRepository, fakeTicketCategoryRepository, factory, identityResolver, domainNotificationHandler, uow, fakeServiceBus);
        }
        public void TestInitialize()
        {
            FakeUnitOfWork = new FakeUnitOfWork();

            Mapper = new Mapper(new MapperConfiguration(c => c.AddProfile(new MappingProfile())));

            Logger = new Mock <ILogger <TrucksController> >();

            TruckService = new Mock <TruckService>(FakeUnitOfWork, Mapper);

            Controller = new TrucksController(Logger.Object, TruckService.Object);
        }
    public void BeginTransactionSucceeds()
    {
        var mockedContext  = new Mock <DbContext>();
        var mockedDatabase = new Mock <DatabaseFacade>(mockedContext.Object);

        mockedDatabase.Setup(facade => facade.BeginTransaction())
        .Returns(new Mock <IDbContextTransaction>().Object);
        mockedContext.SetupGet(context => context.Database)
        .Returns(mockedDatabase.Object);
        var unitOfWork = new FakeUnitOfWork(mockedContext.Object);

        unitOfWork.BeginTransaction().Should().NotBeNull().And.BeOfType <EntityFrameworkTransaction>();
        mockedDatabase.Verify(facade => facade.BeginTransaction(), Times.Once);
    }
Esempio n. 19
0
 static void Main(string[] args)
 {
     try
     {
         IUnitOfWork unitOfWork = new FakeUnitOfWork();
         var person = unitOfWork.GetRepository<Person>();
         person.Add(new Person(){FirstNames = "Billy", Surname = "Bob"});
         unitOfWork.Commit();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw;
     }
 }
Esempio n. 20
0
        public void Dispose_FalseDispose_Success()
        {
            // Arrange
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <DbContext>().UseInMemoryDatabase(nameof(Dispose_FalseDispose_Success));
            var unitOfWork = new FakeUnitOfWork(
                dbContext => new FakeRepository(dbContext),
                dbContextOptionsBuilder.Options,
                "dbo"
                );

            // Act
            unitOfWork.DoNotDispose();

            // Assert
            Assert.NotNull(unitOfWork.FakeEntityRepository);
        }
        public void MerchantsCrud_Create_Test()
        {
            // arrange
            List <Merchant> merchants = new List <Merchant>();
            Merchant        merch     = new Merchant {
                Name = MERCHANT1
            };

            FakeUnitOfWork          fakeUnit = new FakeUnitOfWork(merchants);
            MerchantsCrudController target   = new MerchantsCrudController(fakeUnit);

            // act
            target.Create(merch);

            // assert
            Assert.AreEqual(MERCHANT1, merchants[0].Name);
        }
        public async Task CommitAsync_InsertNewEntity_AffectedOneRow()
        {
            // Arrange
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <DbContext>().UseInMemoryDatabase(nameof(CommitAsync_InsertNewEntity_AffectedOneRow));
            var unitOfWork = new FakeUnitOfWork(
                dbContext => new FakeRepository(dbContext),
                dbContextOptionsBuilder.Options,
                "dbo"
                );

            var entity = new FakeEntity();

            await unitOfWork.FakeEntityRepository.InsertAsync(entity);

            // Act & Assert
            Assert.Equal(1, await unitOfWork.CommitAsync());
        }
Esempio n. 23
0
        public void TestCreateInstance()
        {
            var repoEnt1 = new FakeRepository <EntityModel>(new List <EntityModel>());
            var repoEnt2 = new FakeRepository <EntityModel2>(new List <EntityModel2>());

            var repoList = new List <IRepository>()
            {
                repoEnt1, repoEnt2
            };

            var unitOfWork = new FakeUnitOfWork(repoList);

            var repoEntForCheck1 = unitOfWork.GetRepository <EntityModel>();
            var repoEntForCheck2 = unitOfWork.GetRepository <EntityModel2>();

            Assert.AreEqual(repoEnt1, repoEntForCheck1);
            Assert.AreEqual(repoEnt2, repoEntForCheck2);
        }
Esempio n. 24
0
        public void Dispose_UnitOfWorkWithNullDbContext_Success()
        {
            // Arrange
            FakeUnitOfWork unitOfWork;

            using (unitOfWork = new FakeUnitOfWork())
            {
                Assert.NotNull(unitOfWork.FakeEntityRepository);
            }

            // Act
            unitOfWork.Dispose();

            // Assert
            var repository = unitOfWork.FakeEntityRepository;

            Assert.NotNull(repository);
        }
Esempio n. 25
0
        public void SetUp()
        {
            mockUnitOfWork = new Mock <IUnitOfWork>();
            var fakeData                     = new FakeUnitOfWork();
            var fakeCityRepository           = fakeData.GetStubForCities();
            var fakeForecastsRepository      = fakeData.GetStubForForecasts();
            var fakeHistoryQueriesRepository = fakeData.GetStubForHistoryQueries();

            mockUnitOfWork.Setup(i => i.CityRepository.Get()).Returns(fakeCityRepository);
            mockUnitOfWork.Setup(i => i.ForecastRepository.Get()).Returns(fakeForecastsRepository);
            mockUnitOfWork.Setup(i => i.HistoryRepository.Get()).Returns(fakeHistoryQueriesRepository);

            mockUnitOfWork.Setup(i => i.CityRepository.FindById(It.IsAny <int>()))
            .Returns <int>(id => fakeCityRepository.FirstOrDefault(item => item.Id == id));
            mockUnitOfWork.Setup(i => i.ForecastRepository.FindById(It.IsAny <int>()))
            .Returns <int>(id => fakeForecastsRepository.FirstOrDefault(item => item.Id == id));
            mockUnitOfWork.Setup(i => i.HistoryRepository.FindById(It.IsAny <int>()))
            .Returns <int>(id => fakeHistoryQueriesRepository.FirstOrDefault(item => item.Id == id));
        }
        public async Task CommitAsync_UpdateNonexistentEntity_DataStorageException()
        {
            // Arrange
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <DbContext>().UseInMemoryDatabase(nameof(CommitAsync_UpdateNonexistentEntity_DataStorageException));
            var unitOfWork = new FakeUnitOfWork(
                dbContext => new FakeRepository(dbContext),
                dbContextOptionsBuilder.Options,
                "dbo"
                );

            var entity = new FakeEntity {
                Id = -1
            };

            unitOfWork.FakeEntityRepository.Update(entity);

            // Act & Assert
            await Assert.ThrowsAsync <DataStorageException>(async() => await unitOfWork.CommitAsync());
        }
        public void Initialize()
        {
            AutoMapperConfiguration.Configure();
            cities = new Dictionary <Guid, City>();
            cities.Clear();
            Guid id1   = new Guid("c42ae80e-346f-4a4d-b4d9-2834c762a27f");
            Guid id2   = new Guid("e4c61d79-dc41-4f9d-8619-05a4f8a6f9a9");
            Guid id3   = new Guid("be77764a-3283-4f9a-b3e6-eb2e65d0b8e8");
            City city1 = new City
            {
                Id          = id1,
                CityName    = "city1",
                CountryName = "country1"
            };
            City city2 = new City
            {
                Id          = id2,
                CityName    = "city2",
                CountryName = "country1"
            };
            City city3 = new City
            {
                Id          = id3,
                CityName    = "city3",
                CountryName = "country3"
            };

            cities.Add(id1, city1);
            cities.Add(id2, city2);
            cities.Add(id3, city3);

            FakeUnitOfWork unitOfWork = new FakeUnitOfWork();

            unitOfWork.Cities = cities;

            controller = new CitiesController(unitOfWork)
            {
                Request = new HttpRequestMessage()
                {
                    Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
                }
            };
        }
Esempio n. 28
0
        public void Initialize()
        {
            AutoMapperConfiguration.Configure();
            categories = new Dictionary <Guid, Category>();
            categories.Clear();
            Guid     id1       = new Guid("911b3163-0401-49e8-8589-68b86153bb68");
            Guid     id2       = new Guid("cd6aa915-6044-4354-8958-befc3bdfe02e");
            Guid     id3       = new Guid("cd6aa914-6044-4354-8958-befc3bdfe02e");
            Category category1 = new Category
            {
                Id       = id1,
                CatName  = "Category1",
                Approved = false
            };
            Category category2 = new Category
            {
                Id       = id2,
                CatName  = "Category2",
                Approved = true
            };
            Category category3 = new Category
            {
                Id       = id3,
                CatName  = "Category3",
                Approved = true
            };

            categories.Add(id1, category1);
            categories.Add(id2, category2);
            categories.Add(id3, category3);

            FakeUnitOfWork unitOfWork = new FakeUnitOfWork();

            unitOfWork.Categories = categories;
            controller            = new CategoriesController(unitOfWork)
            {
                Request = new HttpRequestMessage()
                {
                    Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
                }
            };
        }
Esempio n. 29
0
        public void Initialize()
        {
            this.db           = new FakeUnitOfWork();
            this.adminService = new AdminService(db);

            int id = 1;

            db.Beers.Add(new Beer
            {
                Id    = id,
                Hider = new RegularUser
                {
                    AppUser = new User
                    {
                        Email    = "*****@*****.**",
                        UserName = "******"
                    }
                }
            });
        }
        public void MerchantsCrud_Index_Test()
        {
            // arrange
            List <Merchant> merchants = new List <Merchant>();

            merchants.Add(new Merchant {
                Name = MERCHANT1
            });

            FakeUnitOfWork          fakeUnit = new FakeUnitOfWork(merchants);
            MerchantsCrudController target   = new MerchantsCrudController(fakeUnit);

            //// act
            var view = (ViewResult)target.Index();

            //// assert
            var model = (List <Merchant>)view.Model;

            Assert.AreEqual(MERCHANT1, model[0].Name);
        }
Esempio n. 31
0
        public async Task persistence_uow_retreive_bag()
        {
            // Verifies that uows are supplied a bag from the contextbag if it exists

            Dictionary <Type, ContextBag> holder = new Dictionary <Type, ContextBag>();

            var bag = new ContextBag();

            bag.Set("test", "test");
            holder[typeof(FakeUnitOfWork)] = bag;

            bag.Set("contextbags.1", holder);

            var context = new Moq.Mock <IIncomingLogicalMessageContext>();
            var next    = new Moq.Mock <Func <Task> >();
            var builder = new Moq.Mock <IBuilder>();
            var uow     = new FakeUnitOfWork();

            builder.Setup(x => x.BuildAll <IApplicationUnitOfWork>()).Returns(new IApplicationUnitOfWork[] { uow });
            context.Setup(x => x.MessageId).Returns("1");
            context.Setup(x => x.Message).Returns(new LogicalMessage(new NServiceBus.Unicast.Messages.MessageMetadata(typeof(object)), new object()));
            context.Setup(x => x.Extensions).Returns(bag);
            context.Setup(x => x.Builder).Returns(builder.Object);
            context.Setup(x => x.Headers).Returns(new Dictionary <string, string>());
            context.Setup(x => x.MessageHeaders)
            .Returns(new Dictionary <string, string> {
                [Headers.MessageIntent] = MessageIntentEnum.Send.ToString()
            });

            await _uow.Invoke(context.Object, next.Object);

            next.Verify(x => x(), Moq.Times.Once);

            string test;

            Assert.True(uow.Bag.TryGet <string>("test", out test));
            Assert.AreEqual("test", test);
        }
Esempio n. 32
0
        public void About()
        {
            Agency agency1 = new Agency
            {
                Name = "Agence 1",
                AdditionalInformation = "Description agence 1"
            };

            Agency agency2 = new Agency
            {
                Name = "Agence 2",
                AdditionalInformation = "Description agence 2"
            };

            Announcement announcement1 = new Announcement
            {
                Agency = agency1,
                Description = "Description de l'annonce 1",
                IsAvailable = true,
                Price = 400,
                Ref = "20151018.1",
                Surface = 100,
                Title = "Location Maison"
            };

            Announcement announcement2 = new Announcement
            {
                Agency = agency1,
                Description = "Description de l'annonce 2",
                IsAvailable = true,
                Price = 160000,
                Ref = "20151018.2",
                Surface = 100,
                Title = "Venter Maison"
            };

            ICollection<Agency> fakeAgencies = new List<Agency>(new[] { agency1, agency2 });

            ICollection<Announcement> fakeAnnouncements = new List<Announcement>(new[] { announcement1, announcement2 });

            IUnitOfWork fakeUnitOfWork = new FakeUnitOfWork(fakeAnnouncements,
                fakeAgencies);

            IAnnouncementService fakeAnnouncementService = new FakeAnnouncementService();
            fakeAnnouncementService.UnitOfWork = fakeUnitOfWork;

            IAgencyService fakeAgencyService = new FakeAgencyService();
            fakeAgencyService.UnitOfWork = fakeUnitOfWork;

            // Arrange
            HomeController controller = new HomeController();
            controller.AnnouncementService = fakeAnnouncementService;
            controller.AgencyService = fakeAgencyService;

            // Act
            ViewResult result = controller.About() as ViewResult;

            // Assert
            Assert.AreEqual("Your application description page.", result.ViewBag.Message);

            Assert.AreEqual((result.Model as ICollection<Agency>).Count, 2);
            Assert.AreEqual(typeof(List<Agency>), result.Model.GetType());

            Assert.AreEqual(typeof(List<Announcement>), result.ViewData["Announcements"].GetType());
        }