Sha256: 29e07fd28d27050c56a0e3b47ed72ad72c74d2eb5ac9936277fdb1a81b898fae

Contents?: true

Size: 1.17 KB

Versions: 78

Compression:

Stored size: 1.17 KB

Contents

using System;
using System.Collections.Generic;

namespace Generators.Methods
{
    public class ExceptionTestMethodGenerator : TestMethodGenerator
    {
        protected override string Body 
        {
            get
            {
                switch (TestMethodData.Options.TestedMethodType)
                {
                    case TestedMethodType.Static:
                        return $"Assert.Throws<{ExceptionType}>(() => {TestedClassName}.{TestedMethod}({Input}));";
                    case TestedMethodType.Instance:
                        return $"var sut = new {TestedClassName}();\n    Assert.Throws<{ExceptionType}>(() => sut.{TestedMethod}({Input}));;";
                    case TestedMethodType.Extension:
                        return $"Assert.Throws<{ExceptionType}>(() => {Input}.{TestedMethod}());";
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }

        protected override ISet<string> UsingNamespaces => new HashSet<string> { TestMethodData.Options.ExceptionType.Namespace };

        protected virtual string ExceptionType => TestMethodData.Options.ExceptionType.Name;
    }
}

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
trackler-2.1.0.27 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.26 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.25 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.24 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.23 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.22 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.21 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.20 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.19 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.18 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.17 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.16 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.15 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.14 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.13 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.12 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.11 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.10 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.9 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs
trackler-2.1.0.8 tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs