private async Task TestType(Type type) { string expectedResult = TypeTextProvider.GetTypeText(type); SolutionWithCodeAnalysis solution = SolutionWithCodeAnalysis.GetSolutionForSourceCode(expectedResult); LoadedDocumentWithCodeAnalysis document = await solution.Projects.First().Documents.First().LoadAsync(); string documentText = document.ToSourceCode(); documentText.TrimEnd().Replace("\r", string.Empty).Should().Be(expectedResult.TrimEnd().Replace("\r", string.Empty)); }
public void TestClassWithMinusBinaryOperator() { (new CodeGenerationFile() { Namespaces = { new Namespace("CSharpDom.TestTarget.Classes.OperatorOverloads") { Classes = { new Class("ClassWithMinusOperatorOverload") { Body = new ClassBody() { BinaryOperators = new Collection <BinaryOperator>() { new BinaryOperator(BinaryOperatorType.Minus) { Parameter1Type = new TypeReference("ClassWithMinusOperatorOverload"), Parameter1Name = "parameter1", Parameter2Type = new TypeReference("ClassWithMinusOperatorOverload"), Parameter2Name = "parameter2", ReturnType = new TypeReference("TestClass"), Body = new Collection <Statement>() { new ReturnStatement() { RawExpression = "default(ClassWithMinusOperatorOverload)" } } } } } } } } } }).ToString().Should().Be(TypeTextProvider.GetTypeText(typeof(ClassWithMinusOperatorOverload))); }