コード例 #1
0
        public void AuditDecorator_Calls_Query()
        {
            var queryHandler = new TestQueryHandler();
            var query        = new TestQuery("Value");
            var decorator    = new AuditDecorator <TestQuery, string>(_context, _serializer)
            {
                Handler = queryHandler
            };

            var result = decorator.Execute(query);

            result.Should().Be("Results");
        }
コード例 #2
0
        public void AuditDecorator_Calls_Command()
        {
            var commandHandler = new TestCommandHandler();
            var command        = new TestCommand("Value");
            var decorator      = new AuditDecorator <TestCommand>(_repository, _serializer)
            {
                Handler = commandHandler
            };

            var result = decorator.Execute(command);

            result.Errors.Should().HaveCount(1);
            result.Errors.First().Message.Should().Be("Error success");
        }
コード例 #3
0
        public void AuditDecorator_Succeeds()
        {
            var commandHandler = new TestCommandHandler();
            var command        = new TestCommand("Value");
            var decorator      = new AuditDecorator <TestCommand>(_repository, _serializer)
            {
                Handler = commandHandler
            };

            decorator.Execute(command);

            _context.CommandExecutions.Should().HaveCount(1);
            _context.CommandExecutions.First().Date.Should().BeCloseTo(DateTime.UtcNow, 1000);
            _context.CommandExecutions.First().CommandType.Should().Be("AzurePlayground.CommandHandlers.Tests.Decorators.AuditDecoratorTests+TestCommand");
            _context.CommandExecutions.First().CommandData.Should().Be(_serializer.SerializeToJson(command));
        }
コード例 #4
0
        public void AuditDecorator_Succeeds()
        {
            var queryHandler = new TestQueryHandler();
            var query        = new TestQuery("Value");
            var decorator    = new AuditDecorator <TestQuery, string>(_context, _serializer)
            {
                Handler = queryHandler
            };

            decorator.Execute(query);

            _context.QueryExecutions.Should().HaveCount(1);
            _context.QueryExecutions.First().Date.Should().BeCloseTo(DateTime.UtcNow, 1000);
            _context.QueryExecutions.First().QueryType.Should().Be("AzurePlayground.QueryHandlers.Tests.Decorators.AuditDecoratorTests+TestQuery");
            _context.QueryExecutions.First().QueryData.Should().Be(_serializer.SerializeToJson(query));
            _context.CallsToSaveChanges.Should().Be(1);
        }