Esempio n. 1
0
        public void IntegerConstantsMustNotBeAffectedByDiagnostics()
        {
            var testProgram         = TestAssetsReader.ReadTestAsset("IntegerConstant.cs");
            var expectedDiagnostics = new DiagnosticResult[0];

            VerifyCSharpDiagnostic(testProgram, expectedDiagnostics);
        }
Esempio n. 2
0
        public void MultiplicationDiagnosticsWithVariablesMustBeFixable()
        {
            var badProgram   = TestAssetsReader.ReadTestAsset("MultiplicationsWithVariables.cs");
            var fixedProgram = TestAssetsReader.ReadTestAsset("MultiplicationsWithVariablesFixed.cs");

            VerifyCSharpFix(badProgram, fixedProgram);
        }
Esempio n. 3
0
        public void ASimpleMultiplicationForbiddenDiagnosticMustBeFixable()
        {
            var badProgram   = TestAssetsReader.ReadTestAsset("SimpleMultiplication.cs");
            var fixedProgram = TestAssetsReader.ReadTestAsset("SimpleMultiplicationFixed.cs");

            VerifyCSharpFix(badProgram, fixedProgram);
        }
Esempio n. 4
0
        public void AMultiplicationAssignmentForbiddenDiagnosticMustBeFixable()
        {
            var badProgram   = TestAssetsReader.ReadTestAsset("MultiplicationAssignment.cs");
            var fixedProgram = TestAssetsReader.ReadTestAsset("MultiplicationAssignmentFixed.cs");

            VerifyCSharpFix(badProgram, fixedProgram);
        }
Esempio n. 5
0
        public void FloatLiteralsMustBeInvalidated()
        {
            var testProgram        = TestAssetsReader.ReadTestAsset("FloatLiteral.cs");
            var expectedDiagnostic = new DiagnosticResult {
                Id        = "NES002",
                Message   = "Rework your code to not depend on float nor double",
                Severity  = DiagnosticSeverity.Error,
                Locations = new[] {
                    new DiagnosticResultLocation("Test0.cs", 9, 41)
                }
            };

            VerifyCSharpDiagnostic(testProgram, expectedDiagnostic);
        }
Esempio n. 6
0
        public void CallsToMethodsReturningDoubleMustBeInvalidated()
        {
            var testProgram        = TestAssetsReader.ReadTestAsset("DoubleMethodCall.cs");
            var expectedDiagnostic = new DiagnosticResult {
                Id        = "NES001",
                Message   = "Do not invoke methods that return Double",
                Severity  = DiagnosticSeverity.Error,
                Locations = new[] {
                    new DiagnosticResultLocation("Test0.cs", 9, 23)
                }
            };

            VerifyCSharpDiagnostic(testProgram, expectedDiagnostic);
        }
Esempio n. 7
0
        public void CodeWithMultiplicationAssignmentsMustTriggerAnErrorDiagnostic()
        {
            var testProgram = TestAssetsReader.ReadTestAsset("MultiplicationAssignment.cs");
            var multiplicationAssignmentDiagnostic = new DiagnosticResult {
                Id        = "NES003",
                Message   = "Use bit-shifting multiplication or NESMath.Multiply to multiply two numbers with an algorithm that can be run on the NES CPU",
                Severity  = DiagnosticSeverity.Error,
                Locations = new[] {
                    new DiagnosticResultLocation("Test0.cs", 8, 13)
                }
            };

            VerifyCSharpDiagnostic(testProgram, multiplicationAssignmentDiagnostic);
        }
Esempio n. 8
0
        public void FloatMethodReturnsAndParametersMustBeInvalidated()
        {
            var testProgram         = TestAssetsReader.ReadTestAsset("FloatMethodDeclaration.cs");
            var expectedDiagnostics = new [] {
                new DiagnosticResult {
                    Id        = "NES002",
                    Message   = "Rework your code to not depend on float nor double",
                    Severity  = DiagnosticSeverity.Error,
                    Locations = new[] {
                        new DiagnosticResultLocation("Test0.cs", 7, 10)
                    }
                },
                new DiagnosticResult {
                    Id        = "NES002",
                    Message   = "Rework your code to not depend on float nor double",
                    Severity  = DiagnosticSeverity.Error,
                    Locations = new[] {
                        new DiagnosticResultLocation("Test0.cs", 7, 33)
                    }
                }
            };

            VerifyCSharpDiagnostic(testProgram, expectedDiagnostics);
        }