Skip to content

Commit

Permalink
145 fix custom partial generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevitas committed Apr 20, 2022
1 parent 9614593 commit b9532af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public static ClassCodeGenerator CreateClassCodeGenerator(CodeGeneratorOptions o
throw new ArgumentNullException(nameof(classFilename));
}

if (options.ManagementApi)
if (customPartial)
{
return new ManagementClassCodeGenerator(classDefinition, classFilename, options.Namespace);
return new PartialClassCodeGenerator(classDefinition, classFilename, options.Namespace);
}

return customPartial
? new PartialClassCodeGenerator(classDefinition, classFilename, options.Namespace)
return options.ManagementApi
? new ManagementClassCodeGenerator(classDefinition, classFilename, options.Namespace)
: new DeliveryClassCodeGenerator(classDefinition, classFilename, options.Namespace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ public void CreateClassCodeGenerator_DeliveryClassCodeGenerator_NoCustomPartialP
AssertClassCodeGenerator<DeliveryClassCodeGenerator>(result, classDefinitionCodename, classFileName, ClassCodeGenerator.DefaultNamespace);
}

[Fact]
public void CreateClassCodeGenerator_PartialClassCodeGenerator_Returns()
[Theory]
[InlineData(false)]
[InlineData(true)]
public void CreateClassCodeGenerator_PartialClassCodeGenerator_Returns(bool managementApi)
{
var classDefinitionCodename = "codename";
var classFileName = "classFileName";
var codeGeneratorOptions = new CodeGeneratorOptions
{
ManagementApi = false
ManagementApi = managementApi
};

var result = ClassCodeGeneratorFactory.CreateClassCodeGenerator(codeGeneratorOptions, new ClassDefinition(classDefinitionCodename), classFileName, true);
Expand Down Expand Up @@ -108,23 +110,6 @@ public void CreateClassCodeGenerator_DeliveryClassCodeGenerator_CustomNamespace_
AssertClassCodeGenerator<DeliveryClassCodeGenerator>(result, classDefinitionCodename, classFileName, customNamespace);
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public void CreateClassCodeGenerator_ManagementClassCodeGenerator_WithCustomPartialProperty_Returns(bool customPartial)
{
var classDefinitionCodename = "codename";
var classFileName = "classFileName";
var codeGeneratorOptions = new CodeGeneratorOptions
{
ManagementApi = true
};

var result = ClassCodeGeneratorFactory.CreateClassCodeGenerator(codeGeneratorOptions, new ClassDefinition(classDefinitionCodename), classFileName, customPartial);

AssertClassCodeGenerator<ManagementClassCodeGenerator>(result, classDefinitionCodename, classFileName, ClassCodeGenerator.DefaultNamespace);
}

[Fact]
public void CreateClassCodeGenerator_ManagementClassCodeGenerator_NoCustomPartialProperty_Returns()
{
Expand Down

0 comments on commit b9532af

Please sign in to comment.