diff --git a/test/CadlRanchProjects.Tests/model/inheritance/EnumDiscriminatorTests.cs b/test/CadlRanchProjects.Tests/model/inheritance/EnumDiscriminatorTests.cs index afae42c9a86..5fad6edde98 100644 --- a/test/CadlRanchProjects.Tests/model/inheritance/EnumDiscriminatorTests.cs +++ b/test/CadlRanchProjects.Tests/model/inheritance/EnumDiscriminatorTests.cs @@ -1,10 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; +using System.Net.Http; using System.Threading.Tasks; using _Type.Model.Inheritance.EnumDiscriminator; using _Type.Model.Inheritance.EnumDiscriminator.Models; using AutoRest.TestServer.Tests.Infrastructure; +using Azure; +using Microsoft.Extensions.Hosting; using NUnit.Framework; namespace CadlRanchProjects.Tests @@ -64,20 +68,28 @@ public Task GetFixedEnum() => Test(async (host) => [Test] public Task GetFixedModelMissingDiscriminator() => Test(async (host) => { - var response = await new EnumDiscriminatorClient(host, null).GetExtensibleModelMissingDiscriminatorAsync(); + var response = await new EnumDiscriminatorClient(host, null).GetFixedModelMissingDiscriminatorAsync(); Assert.AreEqual(200, response.GetRawResponse().Status); - Assert.IsNotInstanceOf(response.Value); - Assert.AreEqual(10, response.Value.Weight); + Assert.IsNotInstanceOf(response.Value); + Assert.AreEqual(10, response.Value.Length); }); [Test] - public Task GetFixedModelWrongDiscriminator() => Test(async (host) => + public Task GetFixedModelWrongDiscriminator() => Test((host) => { - var response = await new EnumDiscriminatorClient(host, null).GetExtensibleModelWrongDiscriminatorAsync(); - Assert.AreEqual(200, response.GetRawResponse().Status); - Assert.IsNotInstanceOf(response.Value); - Assert.AreEqual(8, response.Value.Weight); + var client = new EnumDiscriminatorClient(host, null); + var exception = Assert.ThrowsAsync(() => client.GetFixedModelWrongDiscriminatorAsync()); + Assert.IsTrue(exception.Message.Contains("wrongKind")); + return Task.CompletedTask; }); + [Test] + public Task GetFixedModelWrongDiscriminator_Protocol() => Test(async (host) => + { + var client = new EnumDiscriminatorClient(host, null); + var context = new RequestContext(); + var response = await client.GetFixedModelWrongDiscriminatorAsync(context); + Assert.AreEqual(200, response.Status); + }); } } diff --git a/test/CadlRanchProjects.Tests/payload-multipart.cs b/test/CadlRanchProjects.Tests/payload-multipart.cs index 4f358a0641f..c4f95d7d57c 100644 --- a/test/CadlRanchProjects.Tests/payload-multipart.cs +++ b/test/CadlRanchProjects.Tests/payload-multipart.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using System.Threading.Tasks; using AutoRest.TestServer.Tests.Infrastructure; @@ -12,6 +11,7 @@ public class PayloadMultipartTests : CadlRanchTestBase { private string SamplePngPath = Path.Combine(CadlRanchServer.GetSpecDirectory(), "assets", "image.png"); private string SampleJpgPath = Path.Combine(CadlRanchServer.GetSpecDirectory(), "assets", "image.jpg"); + private string SampleJpgPath2 = Path.Combine(CadlRanchServer.GetSpecDirectory(), "assets", "hello.jpg"); [Test] public Task Payload_Multipart_FormData_Basic() => Test(async (host) => @@ -44,17 +44,12 @@ public Task Payload_Multipart_FormData_BinaryArrayParts() => Test(async (host) = }); [Test] + [Ignore("The Cadl Ranch's cadl-ranch-specs/assets folder does not contain a hello.jpg file with the mimetype \"image/jpg\", so this test lacks the necessary input.")] public Task Payload_Multipart_FormData_CheckFileNameAndContentType() => Test(async (host) => { - Address addressX = new Address("X"); - var profileImage = System.IO.File.OpenRead(SampleJpgPath); - var pictures = new Stream[] - { - System.IO.File.OpenRead(SamplePngPath), - System.IO.File.OpenRead(SamplePngPath) - }; - ComplexPartsRequest data = new ComplexPartsRequest("123", addressX, profileImage, pictures); - var response = await new MultiPartClient(host, null).GetFormDataClient().FileArrayAndBasicAsync(data); + var profileImage = System.IO.File.OpenRead(SampleJpgPath2); + MultiPartRequest input = new MultiPartRequest("123", profileImage); + var response = await new MultiPartClient(host, null).GetFormDataClient().CheckFileNameAndContentTypeAsync(input); Assert.AreEqual(204, response.Status); });