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
6 changes: 3 additions & 3 deletions src/Digitall.Dataverse.Testing/FakeOrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void AddRelationships(params RelationshipMetadataBase[] relationships)
}
}

private static readonly Lazy<Dictionary<Type, IOrganizationRequestFake>> DefaultFakes = new(() =>
private static readonly Lazy<Dictionary<Type, IOrganizationRequestFake>> s_defaultFakes = new(() =>
{
var assembly = typeof(IOrganizationRequestFake).Assembly;
var fakeTypes = assembly.GetTypes().Where(type =>
Expand All @@ -161,7 +161,7 @@ public void AddRelationships(params RelationshipMetadataBase[] relationships)
/// </summary>
public void AddDefaultRequests()
{
foreach (var (type, fake) in DefaultFakes.Value)
foreach (var (type, fake) in s_defaultFakes.Value)
{
if (!OrganizationRequestFakes.ContainsKey(type))
{
Expand Down Expand Up @@ -477,7 +477,7 @@ public OrganizationResponse Execute(OrganizationRequest request)
if (OrganizationRequestFakes.TryGetValue(request.GetType(), out var fake))
return fake.Execute(request, this);

if (DefaultFakes.Value.TryGetValue(request.GetType(), out var defaultFake))
if (s_defaultFakes.Value.TryGetValue(request.GetType(), out var defaultFake))
return defaultFake.Execute(request, this);

ErrorFactory.ThrowFault(ErrorCodes.MessageDoesNotExist, $"No implementation found for request of type {request.GetType().Name}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override AssociateResponse Execute(AssociateRequest organizationRequest,
break;
}
default:
ErrorFactory.ThrowFault(ErrorCodes.InvalidArgument, $"Relationship metadata type '{relationshipMetadata!.GetType().Name}' is not supported for Associate");
ErrorFactory.ThrowFault(ErrorCodes.InvalidArgument, $"Relationship metadata type '{relationshipMetadata.GetType().Name}' is not supported for Associate");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal static void Process(
default:
ErrorFactory.ThrowFault(
ErrorCodes.InvalidArgument,
$"Relationship metadata type '{relationshipMetadata!.GetType().Name}' is not supported for deep insert");
$"Relationship metadata type '{relationshipMetadata.GetType().Name}' is not supported for deep insert");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override DisassociateResponse Execute(DisassociateRequest organizationReq
}
else
{
ErrorFactory.ThrowFault(ErrorCodes.InvalidArgument, $"Disassociate only supports ManyToMany relationships; '{relationship.SchemaName}' is of type '{relationshipMetadata!.GetType().Name}'");
ErrorFactory.ThrowFault(ErrorCodes.InvalidArgument, $"Disassociate only supports ManyToMany relationships; '{relationship.SchemaName}' is of type '{relationshipMetadata.GetType().Name}'");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ public partial class Account
[AttributeLogicalName("new_accountcategorycodemultiple")]
public OptionSetValueCollection AccountCategoryCodeMultiple
{
get
{
return GetAttributeValue<OptionSetValueCollection>("new_accountcategorycodemultiple");
}
set
{
OnPropertyChanging();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace Digitall.Dataverse.Testing.Tests.Logic;
/// </summary>
public class TemporalOperatorTests
{
private static readonly DateTime Now = new(2024, 6, 12, 12, 0, 0, DateTimeKind.Utc); // Wednesday
private static readonly DateTime s_now = new(2024, 6, 12, 12, 0, 0, DateTimeKind.Utc); // Wednesday

private static FakeOrganizationService CreateService(params Entity[] entities)
{
var sut = new FakeOrganizationService(new FakeTimeProvider(Now));
var sut = new FakeOrganizationService(new FakeTimeProvider(s_now));
sut.AddRange(entities);
return sut;
}
Expand All @@ -30,8 +30,8 @@ private static FakeOrganizationService CreateService(params Entity[] entities)
[Test]
public async Task LastXHours_MatchesRecordWithinLastXHours()
{
var inside = AccountAt(Now.AddHours(-2));
var outside = AccountAt(Now.AddHours(-10));
var inside = AccountAt(s_now.AddHours(-2));
var outside = AccountAt(s_now.AddHours(-10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -45,8 +45,8 @@ public async Task LastXHours_MatchesRecordWithinLastXHours()
[Test]
public async Task LastXDays_MatchesRecordWithinLastXDays()
{
var inside = AccountAt(Now.AddDays(-3));
var outside = AccountAt(Now.AddDays(-10));
var inside = AccountAt(s_now.AddDays(-3));
var outside = AccountAt(s_now.AddDays(-10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -60,8 +60,8 @@ public async Task LastXDays_MatchesRecordWithinLastXDays()
[Test]
public async Task Last7Days_MatchesRecordWithinLast7Days()
{
var inside = AccountAt(Now.AddDays(-5));
var outside = AccountAt(Now.AddDays(-10));
var inside = AccountAt(s_now.AddDays(-5));
var outside = AccountAt(s_now.AddDays(-10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -75,8 +75,8 @@ public async Task Last7Days_MatchesRecordWithinLast7Days()
[Test]
public async Task LastXWeeks_MatchesRecordWithinLastXWeeks()
{
var inside = AccountAt(Now.AddDays(-10)); // ~1.4 weeks ago
var outside = AccountAt(Now.AddDays(-30)); // ~4.3 weeks ago
var inside = AccountAt(s_now.AddDays(-10)); // ~1.4 weeks ago
var outside = AccountAt(s_now.AddDays(-30)); // ~4.3 weeks ago
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -90,8 +90,8 @@ public async Task LastXWeeks_MatchesRecordWithinLastXWeeks()
[Test]
public async Task LastXMonths_MatchesRecordWithinLastXMonths()
{
var inside = AccountAt(Now.AddMonths(-2));
var outside = AccountAt(Now.AddMonths(-6));
var inside = AccountAt(s_now.AddMonths(-2));
var outside = AccountAt(s_now.AddMonths(-6));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -105,8 +105,8 @@ public async Task LastXMonths_MatchesRecordWithinLastXMonths()
[Test]
public async Task LastXYears_MatchesRecordWithinLastXYears()
{
var inside = AccountAt(Now.AddYears(-1));
var outside = AccountAt(Now.AddYears(-5));
var inside = AccountAt(s_now.AddYears(-1));
var outside = AccountAt(s_now.AddYears(-5));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -124,8 +124,8 @@ public async Task LastXYears_MatchesRecordWithinLastXYears()
[Test]
public async Task NextXHours_MatchesRecordWithinNextXHours()
{
var inside = AccountAt(Now.AddHours(3));
var outside = AccountAt(Now.AddHours(10));
var inside = AccountAt(s_now.AddHours(3));
var outside = AccountAt(s_now.AddHours(10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -139,8 +139,8 @@ public async Task NextXHours_MatchesRecordWithinNextXHours()
[Test]
public async Task NextXDays_MatchesRecordWithinNextXDays()
{
var inside = AccountAt(Now.AddDays(3));
var outside = AccountAt(Now.AddDays(10));
var inside = AccountAt(s_now.AddDays(3));
var outside = AccountAt(s_now.AddDays(10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -154,8 +154,8 @@ public async Task NextXDays_MatchesRecordWithinNextXDays()
[Test]
public async Task Next7Days_MatchesRecordWithinNext7Days()
{
var inside = AccountAt(Now.AddDays(5));
var outside = AccountAt(Now.AddDays(10));
var inside = AccountAt(s_now.AddDays(5));
var outside = AccountAt(s_now.AddDays(10));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -169,8 +169,8 @@ public async Task Next7Days_MatchesRecordWithinNext7Days()
[Test]
public async Task NextXWeeks_MatchesRecordWithinNextXWeeks()
{
var inside = AccountAt(Now.AddDays(10));
var outside = AccountAt(Now.AddDays(30));
var inside = AccountAt(s_now.AddDays(10));
var outside = AccountAt(s_now.AddDays(30));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -184,8 +184,8 @@ public async Task NextXWeeks_MatchesRecordWithinNextXWeeks()
[Test]
public async Task NextXMonths_MatchesRecordWithinNextXMonths()
{
var inside = AccountAt(Now.AddMonths(2));
var outside = AccountAt(Now.AddMonths(6));
var inside = AccountAt(s_now.AddMonths(2));
var outside = AccountAt(s_now.AddMonths(6));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -199,8 +199,8 @@ public async Task NextXMonths_MatchesRecordWithinNextXMonths()
[Test]
public async Task NextXYears_MatchesRecordWithinNextXYears()
{
var inside = AccountAt(Now.AddYears(1));
var outside = AccountAt(Now.AddYears(5));
var inside = AccountAt(s_now.AddYears(1));
var outside = AccountAt(s_now.AddYears(5));
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -218,8 +218,8 @@ public async Task NextXYears_MatchesRecordWithinNextXYears()
[Test]
public async Task OlderThanXMinutes_MatchesRecordOlderThanXMinutes()
{
var old = AccountAt(Now.AddMinutes(-30));
var recent = AccountAt(Now.AddMinutes(-5));
var old = AccountAt(s_now.AddMinutes(-30));
var recent = AccountAt(s_now.AddMinutes(-5));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -233,8 +233,8 @@ public async Task OlderThanXMinutes_MatchesRecordOlderThanXMinutes()
[Test]
public async Task OlderThanXHours_MatchesRecordOlderThanXHours()
{
var old = AccountAt(Now.AddHours(-10));
var recent = AccountAt(Now.AddHours(-1));
var old = AccountAt(s_now.AddHours(-10));
var recent = AccountAt(s_now.AddHours(-1));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -248,8 +248,8 @@ public async Task OlderThanXHours_MatchesRecordOlderThanXHours()
[Test]
public async Task OlderThanXDays_MatchesRecordOlderThanXDays()
{
var old = AccountAt(Now.AddDays(-20));
var recent = AccountAt(Now.AddDays(-2));
var old = AccountAt(s_now.AddDays(-20));
var recent = AccountAt(s_now.AddDays(-2));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -263,8 +263,8 @@ public async Task OlderThanXDays_MatchesRecordOlderThanXDays()
[Test]
public async Task OlderThanXWeeks_MatchesRecordOlderThanXWeeks()
{
var old = AccountAt(Now.AddDays(-30));
var recent = AccountAt(Now.AddDays(-5));
var old = AccountAt(s_now.AddDays(-30));
var recent = AccountAt(s_now.AddDays(-5));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -278,8 +278,8 @@ public async Task OlderThanXWeeks_MatchesRecordOlderThanXWeeks()
[Test]
public async Task OlderThanXMonths_MatchesRecordOlderThanXMonths()
{
var old = AccountAt(Now.AddMonths(-6));
var recent = AccountAt(Now.AddMonths(-1));
var old = AccountAt(s_now.AddMonths(-6));
var recent = AccountAt(s_now.AddMonths(-1));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -293,8 +293,8 @@ public async Task OlderThanXMonths_MatchesRecordOlderThanXMonths()
[Test]
public async Task OlderThanXYears_MatchesRecordOlderThanXYears()
{
var old = AccountAt(Now.AddYears(-5));
var recent = AccountAt(Now.AddYears(-1));
var old = AccountAt(s_now.AddYears(-5));
var recent = AccountAt(s_now.AddYears(-1));
var sut = CreateService(old, recent);

var query = new QueryExpression(Account.EntityLogicalName);
Expand Down Expand Up @@ -419,8 +419,8 @@ public async Task ThisWeek_MatchesRecordInCurrentWeek()
public async Task LastWeek_MatchesRecordInPreviousWeek()
{
// Now = 2024-06-12 (Wednesday). 7 days before (Jun 5) should be "last week".
var inside = AccountAt(Now.AddDays(-7).Date);
var outside = AccountAt(Now.Date); // this week
var inside = AccountAt(s_now.AddDays(-7).Date);
var outside = AccountAt(s_now.Date); // this week
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand All @@ -435,8 +435,8 @@ public async Task LastWeek_MatchesRecordInPreviousWeek()
public async Task NextWeek_MatchesRecordInNextWeek()
{
// Now = 2024-06-12 (Wednesday). 7 days after (Jun 19) should be "next week".
var inside = AccountAt(Now.AddDays(7).Date);
var outside = AccountAt(Now.Date); // this week
var inside = AccountAt(s_now.AddDays(7).Date);
var outside = AccountAt(s_now.Date); // this week
var sut = CreateService(inside, outside);

var query = new QueryExpression(Account.EntityLogicalName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Digitall.Dataverse.Testing.Tests.OrganizationRequests;
/// </summary>
public class AnyAllFilterLinkEntityTests
{
private static readonly Guid CorpAId = Guid.Parse("00000000-0000-0000-0001-000000000001");
private static readonly Guid CorpBId = Guid.Parse("00000000-0000-0000-0001-000000000002");
private static readonly Guid s_corpAId = Guid.Parse("00000000-0000-0000-0001-000000000001");
private static readonly Guid s_corpBId = Guid.Parse("00000000-0000-0000-0001-000000000002");

#region JoinOperator.Any via AnyAllFilterLinkEntity

Expand Down Expand Up @@ -52,7 +52,7 @@ public async Task AnyAllFilter_Any_ReturnsParentWithMatchingLinkedRecord()
});

await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpBId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpBId);
}

/// <summary>
Expand Down Expand Up @@ -139,7 +139,7 @@ public async Task AnyAllFilter_NotAny_ReturnsParentWithoutMatchingLinkedRecord()
// corpA has no contacts pointing to it at all → NOT EXISTS is true → included
// corpB has "John B" → EXISTS is true → NOT EXISTS is false → excluded
await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpAId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpAId);
}

#endregion
Expand Down Expand Up @@ -177,7 +177,7 @@ public async Task AnyAllFilter_NotAll_BehavesLikeAny()

// NotAll = Any: corpB has "John B" contact → included
await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpBId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpBId);
}

#endregion
Expand Down Expand Up @@ -257,7 +257,7 @@ public async Task AnyAllFilter_All_IncludesWhenNoLinkedRecordMatchesCriteria()

// corpA: no contacts → excluded. corpB: contacts exist but none match → included.
await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpBId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpBId);
}

#endregion
Expand Down Expand Up @@ -289,7 +289,7 @@ public async Task AnyAllFilter_Any_NoCriteria_ReturnsParentsWithAnyLinkedRecord(

// corpA: no contacts → excluded. corpB: has contacts → included.
await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpBId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpBId);
}

#endregion
Expand Down Expand Up @@ -332,7 +332,7 @@ public async Task AnyAllFilter_Any_NoDuplicateParentRows()

// corpB should appear exactly once even though 2 contacts match
await Assert.That(result.Entities).Count().IsEqualTo(1);
await Assert.That(result.Entities[0].Id).IsEqualTo(CorpBId);
await Assert.That(result.Entities[0].Id).IsEqualTo(s_corpBId);
}

#endregion
Expand Down
Loading
Loading