コード例 #1
0
        public void Get_TypeMismatch_ShouldThrowException()
        {
            // Arrange
            var key     = $"{Guid.NewGuid():N}";
            var value   = new Test();
            var context = new CommandHandlingContext();

            context.Set(key, value);

            // Act / Assert
            Action action = () => context.Get <int>(key);

            action.Should().Throw <InvalidCastException>();
        }
コード例 #2
0
        public void GetUnitOfWork_ShouldGetCorrectProperty()
        {
            // Arrange
            var unitOfWork = new UnitOfWork <string, object>();
            var context    = new CommandHandlingContext();

            context.Set(CommandHandlingContextExtensions.UnitOfWorkKey, unitOfWork);

            // Act
            var unitOfWorkFromContext = context.GetUnitOfWork <string, object>();

            // Assert
            unitOfWorkFromContext.Should().Be(unitOfWork);
        }
コード例 #3
0
        public void SetGet_ShouldReturnValue()
        {
            // Arrange
            var key     = $"{Guid.NewGuid():N}";
            var value   = new Test();
            var context = new CommandHandlingContext();

            // Act
            context.Set(key, value);
            var result = context.Get <Test>(key);

            // Assert
            result.Should().Be(value);
        }