< Summary - Core.Tests

Information
Class: Common.Core.Models.Postcode
Assembly: Common.Core
File(s): D:\a\NuGetPackages\NuGetPackages\src\Common\Core\Models\Postcode.cs
Tag: 3_8508158812
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 46
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Code()100%11100%
get_Province()100%11100%
get_County()100%11100%
get_City()100%11100%
Read(...)100%11100%

File(s)

D:\a\NuGetPackages\NuGetPackages\src\Common\Core\Models\Postcode.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using System.Data;
 3using Common.Core.Classes;
 4
 5namespace Common.Core.Models;
 6
 7/// <summary>Post code details.</summary>
 8public class Postcode : ModelData
 9{
 10  /// <inheritdoc/>
 111  public override int Id { get; set; }
 12
 13  /// <summary>Gets or sets the Postal Service code.</summary>
 14  [Required]
 15  [MaxLength( 10 )]
 4816  public string Code { get; set; } = string.Empty;
 17
 18  /// <summary>Gets or sets the Province code.</summary>
 19  [Required]
 20  [MaxLength( 10 )]
 4621  public string Province { get; set; } = string.Empty;
 22
 23  /// <summary>Gets or sets the County name.</summary>
 24  [MaxLength( 50 )]
 2325  public string? County { get; set; }
 26
 27  /// <summary>Gets or sets the City name.</summary>
 28  [MaxLength( 50 )]
 2329  public string? City { get; set; }
 30
 31  /// <summary>Builds a Postcode object from a database table row.</summary>
 32  /// <param name="row">Database row containing the Postcode columns.</param>
 33  /// <returns>Postcode object containing the database values.</returns>
 34  /// <remarks>This method assumes that the table column names are the same as the property names.</remarks>
 35  public static Postcode Read( DataRow row )
 136  {
 137    return new Postcode()
 138    {
 139      Id = row.Field<int>( nameof( Id ) ),
 140      Code = row.Field<string>( nameof( Code ) )!,
 141      Province = row.Field<string>( nameof( Province ) )!,
 142      County = row.Field<string>( nameof( County ) )!,
 143      City = row.Field<string>( nameof( City ) )!
 144    };
 145  }
 46}