Esempio n. 1
0
        public void TestThatQueryCallsGetWithTranslationInfoIdentifierOnSystemDataRepository()
        {
            var fixture = new Fixture();

            var systemDataRepositoryMock = MockRepository.GenerateMock <ISystemDataRepository>();

            systemDataRepositoryMock.Stub(m => m.Get <ITranslationInfo>(Arg <Guid> .Is.Anything))
            .Return(DomainObjectMockBuilder.BuildTranslationInfoMock())
            .Repeat.Any();
            systemDataRepositoryMock.Stub(m => m.DataProviderWhoHandlesPaymentsGetAll())
            .Return(DomainObjectMockBuilder.BuildDataProviderMockCollection(true))
            .Repeat.Any();

            var objectMapperMock = MockRepository.GenerateMock <IFoodWasteObjectMapper>();

            objectMapperMock.Stub(m => m.Map <IEnumerable <IDataProvider>, IEnumerable <DataProviderView> >(Arg <IEnumerable <IDataProvider> > .Is.Anything, Arg <CultureInfo> .Is.Anything))
            .Return(fixture.CreateMany <DataProviderView>(3).ToList())
            .Repeat.Any();

            var dataProviderWhoHandlesPaymentsCollectionGetQueryHandler = new DataProviderWhoHandlesPaymentsCollectionGetQueryHandler(systemDataRepositoryMock, objectMapperMock);

            Assert.That(dataProviderWhoHandlesPaymentsCollectionGetQueryHandler, Is.Not.Null);

            var dataProviderWhoHandlesPaymentsCollectionGetQuery = fixture.Build <DataProviderWhoHandlesPaymentsCollectionGetQuery>()
                                                                   .With(m => m.TranslationInfoIdentifier, Guid.NewGuid())
                                                                   .Create();

            dataProviderWhoHandlesPaymentsCollectionGetQueryHandler.Query(dataProviderWhoHandlesPaymentsCollectionGetQuery);

            systemDataRepositoryMock.AssertWasCalled(m => m.Get <ITranslationInfo>(Arg <Guid> .Is.Equal(dataProviderWhoHandlesPaymentsCollectionGetQuery.TranslationInfoIdentifier)));
        }
Esempio n. 2
0
        public void TestThatQueryThrowsArgumentNullExceptionWhenDataProviderWhoHandlesPaymentsCollectionGetQueryIsNull()
        {
            var systemDataRepositoryMock = MockRepository.GenerateMock <ISystemDataRepository>();
            var objectMapperMock         = MockRepository.GenerateMock <IFoodWasteObjectMapper>();

            var dataProviderWhoHandlesPaymentsCollectionGetQueryHandler = new DataProviderWhoHandlesPaymentsCollectionGetQueryHandler(systemDataRepositoryMock, objectMapperMock);

            Assert.That(dataProviderWhoHandlesPaymentsCollectionGetQueryHandler, Is.Not.Null);

            var exception = Assert.Throws <ArgumentNullException>(() => dataProviderWhoHandlesPaymentsCollectionGetQueryHandler.Query(null));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Empty);
            Assert.That(exception.ParamName, Is.EqualTo("query"));
            Assert.That(exception.InnerException, Is.Null);
        }