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); }
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); }
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() ); }
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() ); }
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() ); }
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() ); }