public async Task InvokeThenToUnitAsync_14_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc <StructType, RefType?, string, int, object?, DateTime, StructType?, decimal?, RefType, object, StructType, string, double, object?, Task>(Task.CompletedTask); var funcAsync = new Func <StructType, RefType?, string, int, object?, DateTime, StructType?, decimal?, RefType, object, StructType, string, double, object?, Task>(mockFuncAsync.Object.Invoke); var arg1 = SomeTextStructType; var arg2 = (RefType?)null; var arg3 = TabString; var arg4 = MinusFortyFive; var arg5 = new { Value = PlusTwoHundredPointFive }; var arg6 = Year2015March11H01Min15; var arg7 = (StructType?)null; var arg8 = (decimal?)MinusSeventyFivePointSeven; var arg9 = ZeroIdRefType; var arg10 = new object(); var arg11 = CustomStringStructType; var arg12 = CustomText; var arg13 = PlusFortyOnePointSeventyFive; var arg14 = (object?)null; var actual = await funcAsync.InvokeThenToUnitAsync(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(a => a.Invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14), Times.Once); }
public async Task InvokeAsync_00_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc(Task.CompletedTask); var actual = await Unit.InvokeAsync(mockFuncAsync.Object.Invoke); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(f => f.Invoke(), Times.Once); }
public void Filter_SourceIsAbsent_ExpectNeverCallPredicate() { var source = Optional <StructType> .Absent; var mockPredicate = MockFuncFactory.CreateMockFunc <StructType, bool>(true); _ = source.Filter(mockPredicate.Object.Invoke); mockPredicate.Verify(p => p.Invoke(It.IsAny <StructType>()), Times.Never); }
public async Task FilterAsync_SourceIsAbsent_ExpectNeverCallPredicateAsync() { var source = Optional <RefType?> .Absent; var mockPredicateAsync = MockFuncFactory.CreateMockFunc <RefType?, Task <bool> >(Task.FromResult(true)); _ = await source.FilterAsync(mockPredicateAsync.Object.Invoke); mockPredicateAsync.Verify(p => p.Invoke(It.IsAny <RefType?>()), Times.Never); }
public async Task FilterValueAsync_SourceIsAbsent_ExpectAbsent() { var source = Optional <RefType> .Absent; var mockPredicateAsync = MockFuncFactory.CreateMockFunc <RefType, ValueTask <bool> >(ValueTask.FromResult(true)); var actual = await source.FilterValueAsync(mockPredicateAsync.Object.Invoke); Assert.True(actual.IsAbsent); }
public void Filter_SourceIsAbsent_ExpectAbsent() { var source = Optional <RefType> .Absent; var mockPredicate = MockFuncFactory.CreateMockFunc <RefType, bool>(true); var actual = source.Filter(mockPredicate.Object.Invoke); Assert.True(actual.IsAbsent); }
public async Task FilterAsync_SourceIsPresentAndPredicateResultIsFalse_ExpectAbsent() { var source = Optional <RefType> .Present(PlusFifteenIdRefType); var mockPredicateAsync = MockFuncFactory.CreateMockFunc <RefType, Task <bool> >(Task.FromResult(false)); var actual = await source.FilterAsync(mockPredicateAsync.Object.Invoke); Assert.True(actual.IsAbsent); }
public async Task FilterValueAsync_SourceIsPresentAndPredicateResultIsFalse_ExpectAbsent() { var source = Optional <StructType> .Present(SomeTextStructType); var mockPredicateAsync = MockFuncFactory.CreateMockFunc <StructType, ValueTask <bool> >(ValueTask.FromResult(false)); var actual = await source.FilterValueAsync(mockPredicateAsync.Object.Invoke); Assert.True(actual.IsAbsent); }
public void FlatMap_SourceIsAbsent_ExpectNeverCallMap() { var source = Optional <StructType> .Absent; var result = Optional <RefType> .Present(MinusFifteenIdRefType); var mockMap = MockFuncFactory.CreateMockFunc <StructType, Optional <RefType> >(result); _ = source.FlatMap(mockMap.Object.Invoke); mockMap.Verify(p => p.Invoke(It.IsAny <StructType>()), Times.Never); }
public void Filter_SourceIsPresentAndPredicateResultIsFalse_ExpectAbsent() { var source = Optional <StructType?> .Present(SomeTextStructType); var mockPredicate = MockFuncFactory.CreateMockFunc <StructType?, bool>(false); var actual = source.Filter(mockPredicate.Object.Invoke); Assert.True(actual.IsAbsent); }
public async Task FilterAsync_SourceIsPresentAndPredicateResultIsTrue_ExpectPresent() { var source = Optional <StructType?> .Present(null); var mockPredicateAsync = MockFuncFactory.CreateMockFunc <StructType?, Task <bool> >(Task.FromResult(true)); var actual = await source.FilterAsync(mockPredicateAsync.Object.Invoke); Assert.True(actual.IsPresent); }
public void Filter_SourceIsPresentAndPredicateResultIsTrue_ExpectPresent() { var source = Optional <RefType> .Present(ZeroIdRefType); var mockPredicate = MockFuncFactory.CreateMockFunc <RefType, bool>(true); var actual = source.Filter(mockPredicate.Object.Invoke); Assert.True(actual.IsPresent); }
public async Task FlatMapAsync_SourceIsAbsent_ExpectNeverCallMapAsync() { var source = Optional <RefType> .Absent; var result = Optional <StructType> .Present(SomeTextStructType); var mockMap = MockFuncFactory.CreateMockFunc <RefType, Task <Optional <StructType> > >(Task.FromResult(result)); _ = await source.FlatMapAsync(mockMap.Object.Invoke); mockMap.Verify(p => p.Invoke(It.IsAny <RefType>()), Times.Never); }
public void FlatMap_SourceIsAbsent_ExpectAbsent() { var source = Optional <RefType> .Absent; var result = Optional <RefType> .Present(PlusFifteenIdRefType); var mockMap = MockFuncFactory.CreateMockFunc <RefType, Optional <RefType> >(result); var actual = source.FlatMap(mockMap.Object.Invoke); Assert.True(actual.IsAbsent); }
public async Task FlatMapValueAsync_SourceIsAbsent_ExpectAbsent() { var source = Optional <RefType> .Absent; var result = Optional <StructType> .Present(SomeTextStructType); var mockMap = MockFuncFactory.CreateMockFunc <RefType, ValueTask <Optional <StructType> > >(ValueTask.FromResult(result)); var actual = await source.FlatMapValueAsync(mockMap.Object.Invoke); Assert.True(actual.IsAbsent); }
public async Task InvokeAsync_01_ExpectCallFuncOnce( bool isArgNull) { var mockFuncAsync = MockFuncFactory.CreateMockFunc <RefType?, Task>(Task.CompletedTask); var arg = isArgNull ? null : MinusFifteenIdRefType; var actual = await Unit.InvokeAsync(mockFuncAsync.Object.Invoke, arg); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(f => f.Invoke(arg), Times.Once); }
public void Filter_SourceIsPresent_ExpectCallPredicateOnce( bool isSourceValueNull) { var sourceValue = isSourceValueNull ? null : PlusFifteenIdRefType; var source = Optional <RefType?> .Present(sourceValue); var mockPredicate = MockFuncFactory.CreateMockFunc <RefType?, bool>(false); _ = source.Filter(mockPredicate.Object.Invoke); mockPredicate.Verify(p => p.Invoke(sourceValue), Times.Once); }
public async Task FilterAsync_SourceIsPresent_ExpectCallPredicateAsyncOnce( bool isSourceValueNull) { var sourceValue = isSourceValueNull ? null : (StructType?)SomeTextStructType; var source = Optional <StructType?> .Present(sourceValue); var mockPredicateAsync = MockFuncFactory.CreateMockFunc <StructType?, Task <bool> >(Task.FromResult(false)); _ = await source.FilterAsync(mockPredicateAsync.Object.Invoke); mockPredicateAsync.Verify(p => p.Invoke(sourceValue), Times.Once); }
public async Task InvokeAsync_02_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc <StructType, RefType?, Task>(Task.CompletedTask); var arg1 = SomeTextStructType; var arg2 = (RefType?)null; var actual = await Unit.InvokeAsync(mockFuncAsync.Object.Invoke, arg1, arg2); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(f => f.Invoke(arg1, arg2), Times.Once); }
public void FlatMap_SourceIsPresent_ExpectCallMapOnce( bool isSourceValueNull) { var sourceValue = isSourceValueNull ? null : MinusFifteenIdRefType; var source = Optional <RefType?> .Present(sourceValue); var result = Optional <StructType> .Absent; var mockMap = MockFuncFactory.CreateMockFunc <RefType?, Optional <StructType> >(result); _ = source.FlatMap(mockMap.Object.Invoke); mockMap.Verify(p => p.Invoke(sourceValue), Times.Once); }
public async Task FilterValueAsync_SourceIsPresent_ExpectCallPredicateAsyncOnce( bool isSourceValueNull) { var sourceValue = isSourceValueNull ? null : MinusFifteenIdRefType; var source = Optional <RefType?> .Present(sourceValue); var mockPredicateAsync = MockFuncFactory.CreateMockFunc <RefType?, ValueTask <bool> >(ValueTask.FromResult(false)); _ = await source.FilterValueAsync(mockPredicateAsync.Object.Invoke); mockPredicateAsync.Verify(p => p.Invoke(sourceValue), Times.Once); }
public async Task FlatMapAsync_SourceIsPresent_ExpectResultValue( bool isResultPresent) { var source = Optional <RefType?> .Present(null); var result = isResultPresent ? Optional <StructType?> .Present(SomeTextStructType) : Optional <StructType?> .Absent; var mockMap = MockFuncFactory.CreateMockFunc <RefType?, Task <Optional <StructType?> > >(Task.FromResult(result)); var actual = await source.FlatMapAsync(mockMap.Object.Invoke); Assert.AreEqual(result, actual); }
public async Task FlatMapValueAsync_SourceIsPresent_ExpectCallMapAsyncOnce( bool isSourceValueNull) { var sourceValue = isSourceValueNull ? null : PlusFifteenIdRefType; var source = Optional <RefType?> .Present(sourceValue); var result = Optional <StructType> .Absent; var mockMap = MockFuncFactory.CreateMockFunc <RefType?, ValueTask <Optional <StructType> > >(ValueTask.FromResult(result)); _ = await source.FlatMapValueAsync(mockMap.Object.Invoke); mockMap.Verify(p => p.Invoke(sourceValue), Times.Once); }
public void FlatMap_SourceIsPresent_ExpectResultValue( bool isResultPresent) { var source = Optional <StructType?> .Present(SomeTextStructType); var result = isResultPresent ? Optional <RefType?> .Present(PlusFifteenIdRefType) : Optional <RefType?> .Absent; var mockMap = MockFuncFactory.CreateMockFunc <StructType?, Optional <RefType?> >(result); var actual = source.FlatMap(mockMap.Object.Invoke); Assert.AreEqual(result, actual); }
public async Task InvokeThenToUnitAsync_03_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc <StructType, RefType?, string, Task>(Task.CompletedTask); var funcAsync = new Func <StructType, RefType?, string, Task>(mockFuncAsync.Object.Invoke); var arg1 = SomeTextStructType; var arg2 = (RefType?)null; var arg3 = TabString; var actual = await funcAsync.InvokeThenToUnitAsync(arg1, arg2, arg3); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(f => f.Invoke(arg1, arg2, arg3), Times.Once); }
public async Task InvokeAsync_05_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc <StructType, RefType?, string, int, object?, Task>(Task.CompletedTask); var arg1 = SomeTextStructType; var arg2 = (RefType?)null; var arg3 = TabString; var arg4 = MinusFortyFive; var arg5 = new { Value = PlusTwoHundredPointFive }; var actual = await Unit.InvokeAsync(mockFuncAsync.Object.Invoke, arg1, arg2, arg3, arg4, arg5); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(a => a.Invoke(arg1, arg2, arg3, arg4, arg5), Times.Once); }
public async Task InvokeAsync_08_ExpectCallFuncOnce() { var mockFuncAsync = MockFuncFactory.CreateMockFunc <StructType, RefType?, string, int, object?, DateTime, StructType?, decimal?, Task>(Task.CompletedTask); var arg1 = SomeTextStructType; var arg2 = (RefType?)null; var arg3 = TabString; var arg4 = MinusFortyFive; var arg5 = new { Value = PlusTwoHundredPointFive }; var arg6 = Year2015March11H01Min15; var arg7 = (StructType?)null; var arg8 = (decimal?)MinusSeventyFivePointSeven; var actual = await Unit.InvokeAsync(mockFuncAsync.Object.Invoke, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); Assert.AreEqual(Unit.Value, actual); mockFuncAsync.Verify(a => a.Invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8), Times.Once); }