public void ConvertTrue_ReturnsFalse() { var actual = _converter.Convert(true, typeof(bool), null, null); Assert.IsInstanceOf <bool>(actual); Assert.AreEqual(false, actual); }
public void ShouldThrowIfTargetIsNotABool() { var ibc = new InverseBooleanConverter(); Assert.Throws <InvalidOperationException>(() => ibc.Convert(false, null, null, null)); Assert.Throws <InvalidOperationException>(() => ibc.ConvertBack(false, null, null, null)); Assert.Throws <InvalidOperationException>(() => ibc.Convert(false, typeof(string), null, null)); Assert.Throws <InvalidOperationException>(() => ibc.ConvertBack(false, typeof(string), null, null)); }
public void InverseBooleanConverter_Convert_TrueValueSupplied_FalseReturned() { // Assemble bool suppliedValue = true; // Action object returnedValue = inverseBooleanConverter.Convert(suppliedValue, null, null, null); // Assert returnedValue.Should().Be(false); }
public void VerifyConverterConverts() { var converter = new InverseBooleanConverter(); Assert.Throws <InvalidOperationException>(() => converter.Convert(null, typeof(string), null, null)); var value = converter.Convert(true, typeof(bool), null, null); Assert.IsFalse(value is bool b && b); value = converter.Convert(false, typeof(bool), null, null); Assert.IsTrue(value is bool c && c); }
public void ConvertTest() { var inverse = testConverter.Convert(TestValue, null, null, null); Assert.IsInstanceOfType(inverse, typeof(bool)); Assert.AreEqual(inverse, !TestValue); }
public void ConvertTest() { InverseBooleanConverter converter = new InverseBooleanConverter(); bool b = false; var value = (bool)converter.Convert(b, typeof(bool), null, CultureInfo.CurrentCulture); Assert.IsTrue(value); }
public void Convert_AllPossibleInputs_Converted(bool input, bool expected) { var sut = new InverseBooleanConverter(); var result = sut.Convert(input, typeof(bool), 0, CultureInfo.InvariantCulture); result.Should().Be(expected); }
public void WhenConvertingFalseThenResultIsTrue() { var inverseBooleanConverter = new InverseBooleanConverter(); object result = inverseBooleanConverter.Convert(false, typeof(bool), null, new CultureInfo("en-us")); Assert.IsInstanceOfType(result, typeof(bool)); Assert.AreEqual(result, true); }
public void FalseConvertersToTrue() { var converter = new InverseBooleanConverter(); object output = null; var exception = Record.Exception(() => { output = converter.Convert(false, typeof(bool), null, CurrentCulture); }); Assert.Null(exception); Assert.NotNull(output); Assert.IsType <bool>(output); Assert.True((bool)output); }
private void CheckConvert(object value, bool target, InverseBooleanConverter converter) { var result = converter.Convert(value, null, null, CultureInfo.CurrentCulture); if (result is bool boolean) { Assert.AreEqual(target, boolean); } else { Assert.Fail($"The result should be a boolean but actually is '{result?.GetType().Name ?? "[UNKNOWN]"}'."); } }
public void ShouldInverseABool() { var ibc = new InverseBooleanConverter(); var result = ibc.Convert(false, typeof(bool), null, null); Assert.IsType <bool>(result); Assert.True((bool)result); result = ibc.ConvertBack(result, typeof(bool), null, null); Assert.IsType <bool>(result); Assert.False((bool)result); }
public void Convert_ValueIsNotBoolean_ReturnsFalse() { var result = _target.Convert("hans", typeof(bool), null, CultureInfo.InvariantCulture); Assert.IsTrue((bool)result); }
public void TestConvert(bool value, bool expected) { var actual = _inverseBooleanConverter.Convert(value, null, null, null); Assert.AreEqual(expected, actual); }