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