public void Get_UnknownKey_ShouldReturnDefaultValue() { // Arrange var context = new CommandHandlingContext(); // Act / Assert context.Get <Test>("test").Should().BeNull(); context.Get <int>("test").Should().Be(0); }
public void CreateUnitOfWork_ShouldSetCorrectProperty() { // Arrange var context = new CommandHandlingContext(); var unitOfWork = context.CreateUnitOfWork <string, object>(); // Act var unitOfWorkFromContext = context.Get <UnitOfWork <string, object> >(CommandHandlingContextExtensions.UnitOfWorkKey); // Assert unitOfWorkFromContext.Should().Be(unitOfWork); }
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>(); }
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); }