Skip to content

Commit

Permalink
refactor and add [ExcludeFromCodeCoverage] attribute to up test code …
Browse files Browse the repository at this point in the history
…coverage
  • Loading branch information
bezzad committed Sep 18, 2024
1 parent 14024a6 commit 49da7d9
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 92 deletions.
4 changes: 3 additions & 1 deletion src/Downloader.DummyHttpServer/DummyApiException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Net;
using System.Diagnostics.CodeAnalysis;
using System.Net;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
public class DummyApiException : WebException
{
public DummyApiException(string message)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using static System.Console;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
public class DummyApiExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
Expand Down
2 changes: 2 additions & 0 deletions src/Downloader.DummyHttpServer/DummyData.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Downloader.DummyHttpServer;

/// <summary>
/// Class with helper methods to create random data
/// </summary>
[ExcludeFromCodeCoverage]
public static class DummyData
{
private static Random _rand = new Random(DateTime.Now.GetHashCode());
Expand Down
4 changes: 3 additions & 1 deletion src/Downloader.DummyHttpServer/DummyFileHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
public static class DummyFileHelper
{
public const string TempFilesExtension = ".temp";
Expand Down
2 changes: 2 additions & 0 deletions src/Downloader.DummyHttpServer/DummyLazyStream.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;

namespace Downloader.DummyHttpServer;
Expand All @@ -10,6 +11,7 @@ public enum DummyDataType
Single
}

[ExcludeFromCodeCoverage]
public class DummyLazyStream : Stream
{
private readonly Random _random;
Expand Down
3 changes: 2 additions & 1 deletion src/Downloader.DummyHttpServer/HttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
public class HttpServer
{
private static IMemoryCache _cache = new MemoryCache(new MemoryCacheOptions());
Expand Down
2 changes: 2 additions & 0 deletions src/Downloader.DummyHttpServer/MockMemoryStream.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
public class MockMemoryStream : MemoryStream
{
private readonly long _failureOffset = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/Downloader.DummyHttpServer/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.CodeAnalysis;

namespace Downloader.DummyHttpServer;

[ExcludeFromCodeCoverage]
internal class Startup
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Downloader.Test/Helper/FileLogger.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace Downloader.Extensions.Logging;

[ExcludeFromCodeCoverage]
public class FileLogger : ILogger, IDisposable
{
private volatile bool _disposed;
Expand Down
Loading

0 comments on commit 49da7d9

Please sign in to comment.