Ejemplo n.º 1
0
        public void RepositoryGet_Verify()
        {
            var container      = new AutoMoq.AutoMoqer();
            var repositoryMock = container.GetMock <IDynamoDBContext>();
            var settingMock    = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ApplicationName)
            .Returns(Settings.Default.ApplicationName);
            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            var fakeEpochId = string.Format("{0}-{1}", "123", Guid.NewGuid());

            target.Get(fakeEpochId);

            repositoryMock.Verify(x =>
                                  x.Load <ElmahError>(
                                      It.Is <string>(err =>
                                                     err == fakeEpochId
                                                     ),
                                      It.Is <string>(err =>
                                                     err == Settings.Default.ApplicationName
                                                     ),
                                      It.Is <DynamoDBOperationConfig>(config =>
                                                                      config.OverrideTableName == Settings.Default.ElmahTableName
                                                                      )
                                      ),
                                  Times.Once()
                                  );
        }
Ejemplo n.º 2
0
        public void RepositoryGetAllWithQuery_Verify()
        {
            //arrange
            var container      = new AutoMoq.AutoMoqer();
            var repositoryMock = container.GetMock <IDynamoDBContext>();
            var settingMock    = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ApplicationName)
            .Returns(Settings.Default.ApplicationName);
            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            //act
            target.GetAllWithQuery(ScanOperator.GreaterThan, It.IsAny <ConditionalOperatorValues>(), It.IsAny <object>());

            //assert
            repositoryMock.Verify(x =>
                                  x.Query <ElmahError>(
                                      It.Is <string>(y => y == Settings.Default.ApplicationName),
                                      It.Is <DynamoDBOperationConfig>(config =>
                                                                      config.OverrideTableName == Settings.Default.ElmahTableName &&
                                                                      config.QueryFilter.Single().Operator == ScanOperator.GreaterThan &&
                                                                      config.QueryFilter.Single().PropertyName == "DateTimeId"
                                                                      )
                                      ),
                                  Times.Once()
                                  );
        }
Ejemplo n.º 3
0
        public void RepositoryGetAll_Verify()
        {
            //arrange
            var container      = new AutoMoq.AutoMoqer();
            var repositoryMock = container.GetMock <IDynamoDBContext>();
            var settingMock    = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ApplicationName)
            .Returns(Settings.Default.ApplicationName);
            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            //act
            target.GetAll();

            //assert
            repositoryMock.Verify(x =>
                                  x.FromScan <ElmahError>(
                                      It.IsAny <ScanOperationConfig>(),
                                      It.Is <DynamoDBOperationConfig>(config =>
                                                                      config.OverrideTableName == Settings.Default.ElmahTableName
                                                                      )
                                      ),
                                  Times.Once()
                                  );
        }
Ejemplo n.º 4
0
        public void RepositoryGetAll_VerifyGetAll()
        {
            //arrange
            var ddb = InitialiseClient();

            var container   = new AutoMoq.AutoMoqer();
            var settingMock = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");
            container.SetInstance <IDynamoDBContext>(ddb);

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            var errors = Builder <ElmahError> .CreateListOfSize(3)
                         .All()
                         .With(x => x.ApplicationName = Settings.Default.ApplicationName)
                         .Build();

            foreach (var error in errors)
            {
                ddb.Save(error, DefaultDbOperationConfig);
            }

            //act
            var results = target.GetAll();

            //assert
            results.Count().Should().Equal(3);
        }
Ejemplo n.º 5
0
        public void RepositoryGet_VerifyGet()
        {
            //arrange
            var ddb = InitialiseClient();

            var container   = new AutoMoq.AutoMoqer();
            var settingMock = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ApplicationName)
            .Returns(Settings.Default.ApplicationName);
            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");
            container.SetInstance <IDynamoDBContext>(ddb);

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            var fakeEpochId = string.Format("{0}-{1}", "123", Guid.NewGuid());

            var error = Builder <ElmahError> .CreateNew()
                        .With(x => x.ApplicationName = Settings.Default.ApplicationName)
                        .With(x => x.DateTimeId      = fakeEpochId)
                        .Build();

            ddb.Save(error, DefaultDbOperationConfig);

            //act
            var result = target.Get(fakeEpochId);

            //assert
            result.DateTimeId.Should().Equal(fakeEpochId);
        }
Ejemplo n.º 6
0
        //[Test]
        public void GetErrors_Test_GreaterThanZeroPageIndex_Verify()
        {
            //arrange
            var container = new AutoMoq.AutoMoqer();

            var reposistoryMock = container.GetMock <IRepository <ElmahError> >();

            var target = container.Resolve <ElmahDynamoDbErrorLog>();

            var errors = Builder <ElmahError> .CreateListOfSize(5)
                         .All()
                         .With(x => x.ApplicationName = Settings.Default.ApplicationName)
                         .Build();

            reposistoryMock.Setup(x => x.GetAll())
            .Returns(errors);

            //act
            target.GetErrors(1, 4, new List <ErrorLogEntry>());
            target.GetErrors(1, 4, new List <ErrorLogEntry>());

            ////assert
            //reposistoryMock.Verify(x => x.GetAllWithQuery(
            //    It.Is<ScanOperator>(scanop => scanop == ScanOperator.GreaterThan),
            //    It.IsAny<ConditionalOperatorValues>(),
            //    It.IsAny<object>();
            //    //));

            reposistoryMock.Verify(x => x.GetAllWithQuery(
                                       It.IsAny <ScanOperator>(),
                                       It.IsAny <ConditionalOperatorValues>(),
                                       It.IsAny <object>()));
            //));
        }
        public TransacaoAporteRequestValidatorTest()
        {
            _validator = _moq.Create <TransacaoAporteRequestValidator>();

            _moq.GetMock <IGlobalContainerAccessor>()
            .Setup(x => x.GetInstance(It.Is <Type>(y => y == typeof(IBaseRepository <Conta>))))
            .Returns(_moq.GetMock <IBaseRepository <Conta> >().Object);
        }
Ejemplo n.º 8
0
        public void RepositoryAdd_Verify()
        {
            //arrange
            var container      = new AutoMoq.AutoMoqer();
            var repositoryMock = container.GetMock <IDynamoDBContext>();
            var settingMock    = container.GetMock <ISettings>();

            settingMock.Setup(x => x.ApplicationName)
            .Returns(Settings.Default.ApplicationName);
            settingMock.Setup(x => x.ElmahTableName)
            .Returns(Settings.Default.ElmahTableName);

            container.SetInstance("dummy");

            var target = container.Resolve <DynamoDbRepository <ElmahError> >();

            var fakeEpochId = string.Format("{0}-{1}", "123", Guid.NewGuid());

            var error = Builder <ElmahError> .CreateNew()
                        .With(x => x.ApplicationName = Settings.Default.ApplicationName)
                        .With(x => x.DateTimeId      = fakeEpochId)
                        .Build();

            //act
            target.Add(error);

            //assert
            repositoryMock.Verify(x =>
                                  x.Save(It.Is <ElmahError>(err =>
                                                            error.ApplicationName == Settings.Default.ApplicationName &&
                                                            error.DateTimeId == fakeEpochId
                                                            ),
                                         It.Is <DynamoDBOperationConfig>(config => config.OverrideTableName == Settings.Default.ElmahTableName)
                                         ),
                                  Times.Once()
                                  );
        }
Ejemplo n.º 9
0
        public void GetErrors_Test_ZeroPageIndex_Verify()
        {
            //arrange
            var container = new AutoMoq.AutoMoqer();

            var reposistoryMock = container.GetMock <IRepository <ElmahError> >();

            var target = container.Resolve <ElmahDynamoDbErrorLog>();

            //act
            target.GetErrors(0, It.IsAny <int>(), It.IsAny <List <ErrorLogEntry> >());

            //assert
            reposistoryMock.Verify(x => x.GetAll());
        }
Ejemplo n.º 10
0
 public TransacaoServiceTest()
 {
     _transacaoService = _moq.Create <TransacaoService>();
     _moq.GetMock <ILogFactory>().Setup(x => x.Log());
 }
Ejemplo n.º 11
0
 public void setup()
 {
     mocker.GetMock <ISyncAgent>();
     _sut = mocker.Resolve <ISyncAgent>();
 }