Skip to content

Commit 2ffa43b

Browse files
author
Linh Phan
committed
add test for same enum in different namespaces
1 parent f1d2465 commit 2ffa43b

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

packages/http-client-csharp/emitter/test/Unit/operation-paging.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,45 @@ describe("Next link operations", () => {
355355
`Expected model 'Foo' to be present in code model models. Found: ${root.models.map((m) => m.name).join(", ")}`,
356356
);
357357
});
358+
359+
it("does not deduplicate enums with the same name but different namespaces", async () => {
360+
const program = await typeSpecCompile(
361+
`
362+
@convenientAPI(false)
363+
@list
364+
op link(): {
365+
@pageItems
366+
items: Foo[];
367+
368+
@nextLink
369+
next?: url;
370+
};
371+
enum Status { active, inactive };
372+
namespace Sub {
373+
enum Status { open, closed };
374+
}
375+
model Foo {
376+
name: string;
377+
a: Status;
378+
b: Sub.Status;
379+
};
380+
`,
381+
runner,
382+
{ IsTCGCNeeded: true },
383+
);
384+
const context = createEmitterContext(program);
385+
const sdkContext = await createCSharpSdkContext(context);
386+
const [root] = createModel(sdkContext);
387+
388+
// Two enums share the name "Status" but live in different namespaces.
389+
// The namespace-aware dedup key must keep both in the code model.
390+
const statusEnums = root.enums.filter((e) => e.name === "Status");
391+
strictEqual(
392+
statusEnums.length,
393+
2,
394+
`Expected 2 'Status' enums from different namespaces. Found ${statusEnums.length}: ${root.enums.map((e) => `${e.namespace}.${e.name}`).join(", ")}`,
395+
);
396+
});
358397
});
359398

360399
describe("Continuation token operations", () => {

0 commit comments

Comments
 (0)