public void ThrowIfWrongExceptionThrown(
            [Frozen] Mock<IExecutionSetup> executionSetupMock,
            MethodData method)
        {
            // Arrange
            executionSetupMock
                .Setup(es => es.Setup(method))
                .Returns(() => ExceptionTask(new Exception(method.ToString())));

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

            // Act/Assert
            Exception innerException = Assert.Throws <AggregateException>(() => method.Execute().Wait()).InnerException;

            Assert.IsType <ThrowsException>(innerException);
        }
        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);
        }
Exemplo n.º 4
0
        public void ProvideDebuggerDisplay(MethodData sut)
        {
            // Assert as we go
            DebuggerDisplayAttribute debuggerDisplay = sut.GetType().GetTypeInfo().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);

            string display = Assert.IsType <string>(getMethod.Invoke(sut, new object[] { }));

            Assert.Contains(sut.ToString(), display);
        }