Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Azure.Functions.Cli.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoZipTool", "src\GoZipTool\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cli", "Cli", "{4FC405F4-CF0B-4CD6-8555-A93AF42A27E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.Unit.Tests", "test\Cli\Func.Unit.Tests\Azure.Functions.Cli.Unit.Tests.csproj", "{BBCC9C23-0594-4F5F-8604-B4E032EFC8DE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.UnitTests", "test\Cli\Func.UnitTests\Azure.Functions.Cli.UnitTests.csproj", "{BBCC9C23-0594-4F5F-8604-B4E032EFC8DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion eng/ci/templates/public/steps/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ steps:
displayName: 'Run unit tests'
inputs:
command: 'test'
projects: '**/Azure.Functions.Cli.Unit.Tests.csproj'
projects: '**/Azure.Functions.Cli.UnitTests.csproj'
arguments: '--framework net8.0'

- task: PublishTestResults@2
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/func/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.Tests")]
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.E2E.Tests")]
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.Unit.Tests")]
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.UnitTests")]
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private IFileSystem GetFakeFileSystem(IEnumerable<(string folder, string functio
//fileSystem.File.Exists(Arg.Is(Path.Combine(folder, "function.json"))).Returns(true);

fileSystem.File.Open(Arg.Is(Path.Combine(folder, "function.json")), Arg.Any<FileMode>(), Arg.Any<FileAccess>(), Arg.Any<FileShare>())
.Returns(fileContent.ToStream());
.Returns(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(fileContent)));
}

return fileSystem;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System;
using System.Linq;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.IO.Abstractions;
using Autofac;
using FluentAssertions;
using Azure.Functions.Cli.Actions;
using Azure.Functions.Cli.Actions.AzureActions;
using Azure.Functions.Cli.Actions.DurableActions;
using Azure.Functions.Cli.Actions.HostActions;
using Azure.Functions.Cli.Actions.LocalActions;
using Azure.Functions.Cli.Arm;
using Azure.Functions.Cli.Common;
using Azure.Functions.Cli.Interfaces;
using FluentAssertions;
using NSubstitute;
using Xunit;
using System.IO.Abstractions;

namespace Azure.Functions.Cli.Tests.ActionsTests
namespace Azure.Functions.Cli.UnitTests.ActionsTests
{
public class ResolveActionTests
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public void ThrowErrorOnIncorrectCommandLine(string args)

Assert.Throws<CliArgumentsException>(app.Parse);
}

private IContainer InitializeContainerForTests()
{
var builder = new ContainerBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
<TargetFramework>net8.0</TargetFramework>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<IsPackable>false</IsPackable>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Moq" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="RichardSzalay.MockHttp" />
<PackageReference Include="SuaveServerWrapper" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Xunit.SkippableFact" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System.Runtime.InteropServices;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Runtime.InteropServices;
using Azure.Functions.Cli.Common;
using FluentAssertions;
using Xunit;

namespace Azure.Functions.Cli.Tests
namespace Azure.Functions.Cli.UnitTests
{
public class CommandCheckerFacts
public class CommandCheckerTests
{
[Fact]
public void CommandCheckerShouldWork()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using Azure.Functions.Cli.Diagnostics;
using Microsoft.Azure.WebJobs.Script.Configuration;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Text;
using Azure.Functions.Cli.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Xunit;
using System;

namespace Azure.Functions.Cli.Tests
namespace Azure.Functions.Cli.UnitTests.ConsoleTests
{
public class ColoredConsoleLoggerTests
{
private IConfigurationRoot _testConfiguration;
private readonly IConfigurationRoot _testConfiguration;

public ColoredConsoleLoggerTests()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.IO;
using System.Threading.Tasks;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace Azure.Functions.Cli.Tests
namespace Azure.Functions.Cli.UnitTests
{
public static class Extensions
public static class StreamExtensions
{
public static Stream ToStream(this string value)
{
Expand All @@ -14,10 +14,5 @@ public static Stream ToStream(this string value)
stream.Position = 0;
return stream;
}

public static Task<T> AsTask<T>(this T obj)
{
return Task.FromResult(obj);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Azure.Functions.Cli.Extensions;
using FluentAssertions;
using Xunit;

namespace Azure.Functions.Cli.UnitTests.ExtensionsTests
{
public class GenericExtensionsTests
{
public enum Test
{
North,
South
}

[Fact]
public void MergeWithTest()
{
var source = new Source { Name = "Original", Value = 10, Timestamp = DateTime.UtcNow, Direction = Test.South, From = Test.South };
var target = new Target();

target = target.MergeWith(source, t => t);

target.Name.Should().Be(source.Name);
target.Value.Should().Be(source.Value);
target.Timestamp.Should().Be(source.Timestamp);
target.Direction.Should().Be(source.Direction);
target.From.Should().Be(source.From);
}

public class Source
{
public string Name { get; set; }

public int Value { get; set; }

public DateTime Timestamp { get; set; }

public Test Direction { get; set; }

public Test From { get; set; }
}

public class Target
{
public string Name { get; set; }

public int Value { get; set; }

public DateTime? Timestamp { get; set; }

public Test? Direction { get; set; }

public Test From { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using System.Diagnostics;
using System.Threading.Tasks;
using FluentAssertions;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Diagnostics;
using System.Runtime.InteropServices;
using Azure.Functions.Cli.Extensions;
using FluentAssertions;
using Xunit;
using System.Runtime.InteropServices;

namespace Azure.Functions.Cli.Tests.ExtensionsTests
namespace Azure.Functions.Cli.UnitTests.ExtensionsTests
{
public class ProcessExtensionsTests
{
private volatile bool calledContinueWith = false;
private volatile bool _calledContinueWith = false;

[SkippableFact]
public async Task WaitForExitTest()
{
Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows),
Skip.IfNot(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows),
reason: "Unreliable on linux CI");

Process process = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
Expand All @@ -23,15 +26,16 @@ public async Task WaitForExitTest()

process.CreateWaitForExitTask().ContinueWith(_ =>
{
calledContinueWith = true;
_calledContinueWith = true;
}).Ignore();

process.Kill();
for (var i = 0; !calledContinueWith && i < 10; i++)
for (var i = 0; !_calledContinueWith && i < 10; i++)
{
await Task.Delay(200);
}
calledContinueWith.Should().BeTrue(because: "the process should have exited and called the continuation");

_calledContinueWith.Should().BeTrue(because: "the process should have exited and called the continuation");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Azure.Functions.Cli.Exceptions;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Azure.Functions.Cli.Exceptions;
using Azure.Functions.Cli.Extensions;
using System;
using Xunit;

namespace Azure.Functions.Cli.Tests.ExtensionsTests
namespace Azure.Functions.Cli.UnitTests.ExtensionsTests
{
public class StringExtensionsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Azure.Functions.Cli.Extensions;
using FluentAssertions;
using Xunit;

namespace Azure.Functions.Cli.Tests.ExtensionsTests
namespace Azure.Functions.Cli.UnitTests.ExtensionsTests
{
public class TaskExtensionsTests
{
Expand Down Expand Up @@ -40,6 +40,5 @@ public async Task IgnoreFailureAndFilterListOfTasks()
.And
.Contain(new[] { "test" });
}

}
}
Loading
Loading