Ejemplo n.º 1
0
        public async Task ReadKeysWhenIndexPropertyIsNotIndexed()
        {
            var data   = DataManager.ReadIndexKeys <BasicEntity, string>(x => x.Value1);
            var result = new List <IndexKey <string> >();

            await foreach (var d in data)
            {
                result.Add(d);
            }
            Assert.IsEmpty(result);
            MockIndexer.Verify(x => x.IndexExist <BasicEntity>(It.IsAny <string>()), Times.Never);
        }
Ejemplo n.º 2
0
        public async Task <bool> WriteDataWithAuditWhenIndexingSuccess()
        {
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.Rollback(ExpectedAuditedEntity.Id, ExpectedAuditedEntity), Times.Never);
            MockIndexer
            .Verify(x => x.Index(ExpectedAuditedEntity), Times.Once);
            MockAudit
            .Verify(x => x.RollbackEvent(ExpectedAuditedEntity), Times.Never);
            MockAudit
            .Verify(x => x.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <bool> WriteDataWithAuditWhenAuditCommitFails()
        {
            MockAudit
            .Setup(x => x.CommitEvents(ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.Rollback(ExpectedAuditedEntity.Id, ExpectedAuditedEntity), Times.Once);
            MockIndexer
            .Verify(x => x.Index(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Ejemplo n.º 4
0
        public async Task <bool> WriteNewDataWithAuditWhenIndexingSuccess()
        {
            MockDataStream
            .Setup(x => x.Exists <AuditedEntity>(ExpectedAuditedEntity.Id))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.Rollback(ExpectedAuditedEntity.Id, (DataEntity)null), Times.Never);
            MockIndexer
            .Verify(x => x.Index(ExpectedAuditedEntity), Times.Once);
            MockAudit
            .Verify(x => x.RollbackEvent(ExpectedAuditedEntity), Times.Never);
            MockAudit
            .Verify(x => x.UpdateEvent(It.IsAny <DataEntity>(), It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Ejemplo n.º 5
0
        public async Task <bool> WriteDataWithNoAuditFails()
        {
            MockDataStream
            .Setup(x => x.WriteAndCommit(It.IsAny <int>(), It.IsAny <DataEntity>()))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedBasicEntity1);

            MockDataStream
            .Verify(x => x.Rollback(It.IsAny <int>(), It.IsAny <DataEntity>()), Times.Never);
            MockIndexer
            .Verify(x => x.Index(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.UpdateEvent(It.IsAny <DataEntity>(), It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CommitEvents(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }
Ejemplo n.º 6
0
        public async Task <bool> WriteDataWithAuditUpdateEventFails()
        {
            MockAudit
            .Setup(x => x.UpdateEvent(ExpectedAuditedEntity, ExpectedAuditedEntity))
            .ReturnsAsync(false);
            var result = await DataManager.Write(ExpectedAuditedEntity);

            MockDataStream
            .Verify(x => x.DiscardChanges <BasicEntity>(ExpectedAuditedEntity.Id));
            MockDataStream
            .Verify(x => x.Commit <BasicEntity>(It.IsAny <int>()), Times.Never);
            MockDataStream
            .Verify(x => x.Rollback(It.IsAny <int>(), It.IsAny <DataEntity>()), Times.Never);
            MockIndexer
            .Verify(x => x.Index(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CreationEvent(It.IsAny <DataEntity>()), Times.Never);
            MockAudit
            .Verify(x => x.CommitEvents(It.IsAny <DataEntity>()), Times.Never);
            return(result);
        }