Refactor to introduce nullable types and reduce compiler warnings (#801)

* Introduce nullable types to Core, Infrastructure and PublicApi projects

* Refactor unit tests

* Fixed failing tests

* Introduce Parameter object for CatalogItem update method

* Refactor CataloItemDetails param object

* Refactor following PR comments
This commit is contained in:
Philippe Vaillancourt
2022-10-04 16:57:40 +01:00
committed by GitHub
parent aa6305eab1
commit a72dd775ee
51 changed files with 168 additions and 256 deletions

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Extensions;
@@ -9,12 +6,22 @@ public class TestParent : IEquatable<TestParent>
{
public int Id { get; set; }
public string Name { get; set; }
public string? Name { get; set; }
public IEnumerable<TestChild> Children { get; set; }
public IEnumerable<TestChild>? Children { get; set; }
public bool Equals([AllowNull] TestParent other) =>
other?.Id == Id && other?.Name == Name &&
(other?.Children is null && Children is null ||
(other?.Children?.Zip(Children)?.All(t => t.First?.Equals(t.Second) ?? false) ?? false));
public bool Equals([AllowNull] TestParent other)
{
if (other?.Id == Id && other?.Name == Name)
{
if (Children is null)
{
return other?.Children is null;
}
return other?.Children?.Zip(Children).All(t => t.First?.Equals(t.Second) ?? false) ?? false;
}
return false;
}
}