public void NotDefaultCheckShouldNotThrowExceptionIfIntegerVariableHasNotDefaultValue() { // Arrange int variableName = 5; // Act IEnsurable <int> result = Ensure.NotDefault(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotDefaultCheckShouldNotThrowExceptionIfNullableStructIsSetToDefaultValue() { // Arrange Guid?variableName = Guid.Empty; // Act IEnsurable <Guid> result = Ensure.NotDefault(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotDefaultCheckShouldNotThrowExceptionIfVariableIsNotNull() { // Arrange string variableName = "Test"; // Act IEnsurable <string> result = Ensure.NotDefault(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullOrWhiteSpaceCheckShouldNotThrowExceptionIfVariableStartsAndEndsWithWhiteSpaceCharacters() { // Arrange string variableName = " . "; // Act IEnsurable <string> result = Ensure.NotNullOrWhiteSpace(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotDefaultCheckShouldNotThrowExceptionIfGuidVariableIsSetToNewGuid() { // Arrange Guid variableName = Guid.NewGuid(); // Act IEnsurable <Guid> result = Ensure.NotDefault(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullCheckShouldNotThrowArgumentNullExceptionForNotNullStructValue() { // Arrange int?variableName = 5; // Act IEnsurable <int> result = Ensure.NotNull(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotDefaultCheckShouldReturnNonNullableTypeBackWhenNullableReferenceTypeIsSpecified() { // Arrange // ReSharper disable once VariableCanBeNotNullable Queue <string>?variableName = new Queue <string>(); // Act IEnsurable <Queue <string> > result = Ensure.NotDefault(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullOrEmptyListCheckShouldNotThrowExceptionIfVariableIsNotEmpty() { // Arrange List <string> variableName = new List <string> { "element" }; // Act IEnsurable <List <string> > result = Ensure.NotNullOrEmpty(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullOrEmptyListCheckShouldNotThrowExceptionIfListOfNullableStructIsNotNullOrEmpty() { // Arrange List <Guid?> variableName = new List <Guid?> { Guid.NewGuid(), null }; // Act IEnsurable <List <Guid?> > result = Ensure.NotNullOrEmpty(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullOrEmptyListCheckShouldNotThrowExceptionIfQueueVariableIsNotEmpty() { // Arrange Queue <string> variableName = new Queue <string>(); variableName.Enqueue("element-1"); variableName.Enqueue("element-2"); // Act IEnsurable <Queue <string> > result = Ensure.NotNullOrEmpty(variableName, nameof(variableName)); // Assert Assert.Equal(result.Value, variableName); }
public void NotNullOrEmptyGenericDictionaryCheckShouldNotThrowExceptionIfIsNotEmpty() { // Arrange IDictionary <string, string> variableName = new Dictionary <string, string> { { "Key", "Value" } }; // Act IEnsurable <IDictionary <string, string> > result1 = Ensure.NotNullOrEmpty(variableName, nameof(variableName)); IEnsurable <IDictionary <string, string> > result2 = Ensure.NotNullOrEmpty(variableName); // Assert Assert.Equal(result1.Value, variableName); Assert.Equal(result2.Value, variableName); }