public void InitialiseProperties(
            Type classUnderTest,
            object instanceUnderTest,
            MethodBase methodUnderTest,
            object[] parameters,
            string nullParameter,
            int nullIndex,
            IExecutionSetup executionSetup)
        {
            // Act
            var sut = new MethodData(
                classUnderTest,
                instanceUnderTest,
                methodUnderTest,
                parameters,
                nullParameter,
                nullIndex,
                executionSetup);

            // Assert
            Assert.Same(classUnderTest, sut.ClassUnderTest);
            Assert.Equal(instanceUnderTest, sut.InstanceUnderTest);
            Assert.Same(methodUnderTest, sut.MethodUnderTest);
            Assert.Same(parameters, sut.Parameters);
            Assert.Same(nullParameter, sut.NullParameter);
            Assert.Equal(nullIndex, sut.NullIndex);
            Assert.Same(executionSetup, sut.ExecutionSetup);
        }
        public Task DoNothingWhenCorrectArgumentNullExceptionThrown(
            [Frozen] Mock<IExecutionSetup> executionSetupMock,
            MethodData method)
        {
            // Arrange
            executionSetupMock
                .Setup(es => es.Setup(method))
                .Returns(() => ExceptionTask(new ArgumentNullException(method.NullParameter)));

            // Act
            return method.Execute();
        }
        public void ThrowIfNoExceptionThrown(
            [Frozen] Mock<IExecutionSetup> executionSetupMock,
            MethodData method)
        {
            // Arrange
            executionSetupMock
                .Setup(es => es.Setup(method))
                .Returns(() => CompletedTask());

            // Act/Assert
            Exception innerException = Assert.Throws<AggregateException>(() => method.Execute().Wait()).InnerException;
            Assert.IsType<ThrowsException>(innerException);
        }
        public void ThrowIfWrongArgumentNullExceptionThrown(
            [Frozen] Mock<IExecutionSetup> executionSetupMock,
            MethodData method)
        {
            // Arrange
            executionSetupMock
                .Setup(es => es.Setup(method))
                .Returns(() => ExceptionTask(new ArgumentNullException(Guid.NewGuid().ToString())));

            // Act/Assert
            Exception innerException = Assert.Throws<AggregateException>(() => method.Execute().Wait()).InnerException;
            Assert.IsType<EqualException>(innerException);
        }
        public async Task ExplicitEquals(MethodData method)
        {
            await method.Execute();

            if (method.NullParameter == "stringValue1")
                Assert.True(Issues.Issue015.ExplicitEquals.TestedStringValue1);

            if (method.NullParameter == "stringValue2")
                Assert.True(Issues.Issue015.ExplicitEquals.TestedStringValue2);

            if (method.NullParameter == "stringValue3")
                Assert.True(Issues.Issue015.ExplicitEquals.TestedStringValue3);
        }
        public void ProvideDebuggerDisplay(MethodData sut)
        {
            // Assert as we go
            var debuggerDisplay = sut.GetType().GetCustomAttribute<DebuggerDisplayAttribute>(inherit: false);
            Assert.NotNull(debuggerDisplay);
            Assert.Contains("DebuggerDisplay", debuggerDisplay.Value);

            PropertyInfo propertyInfo = sut.GetType().GetProperty("DebuggerDisplay", BindingFlags.NonPublic | BindingFlags.Instance);
            Assert.NotNull(propertyInfo);

            MethodInfo getMethod = propertyInfo.GetGetMethod(true);
            Assert.NotNull(getMethod);

            var display = Assert.IsType<string>(getMethod.Invoke(sut, new object[] { }));
            Assert.Contains(sut.ToString(), display);
        }
        public async Task Simple(MethodData method)
        {
            await method.Execute();

            Assert.True(SimpleGenericMethods.GenericMethod2Tested);
        }
 public Task TestAllNullArguments(MethodData method)
 {
     return method.Execute();
 }
        public async Task TestStringInput(MethodData method)
        {
            await method.Execute();

            Assert.True(SomeNullableValueTypeParameters.StringInputTested);
        }
        public async Task TestStringRef(MethodData method)
        {
            await method.Execute();

            Assert.True(SomeOutParameters.StringRefTested);
        }
        public async Task TestNullArguments(MethodData method)
        {
            await method.Execute();

            Assert.True(YieldExample.Tested);
        }
        public async Task ImplicitEquals(MethodData method)
        {
            await method.Execute();

            Assert.True(Issues.Issue015.ImplicitEquals.Tested);
        }
        public async Task TestNullArguments(MethodData method)
        {
            await method.Execute();

            Assert.True(SpecialCharacters.Tested);
        }
        public async Task ComplexGenericExceptionMethodStringValue(MethodData method)
        {
            await method.Execute();

            Assert.True(ComplexGenericMethods.GenericExceptionMethodStringValueTested);
        }
        public async Task SimpleException(MethodData method)
        {
            await method.Execute();

            Assert.True(SimpleGenericMethods.GenericExceptionMethodTested);
        }
 public async Task TestGenericClass(MethodData method)
 {
     await method.Execute();
     Assert.True(GenericClass<Version>.Tested);
 }
        public async Task ComplexClassValue(MethodData method)
        {
            await method.Execute();

            Assert.True(ComplexGenericMethods.ClassValueTested);
        }
        public async Task InterfaceStringValue(MethodData method)
        {
            await method.Execute();

            Assert.True(InterfaceGenericMethods.StringValueTested);
        }
        public async Task MixedStringValue(MethodData method)
        {
            await method.Execute();

            Assert.True(MixedGenericMethods.StringValueTested);
        }
Пример #20
0
 public Task CloudFlare(MethodData method)
 {
     return method.Execute();
 }
 public async Task OnlyTestPublic(MethodData method)
 {
     await method.Execute();
     Assert.True(Mixture.Tested);
 }