Skip to content

Commit

Permalink
Convert solution to use implicit usings (#567)
Browse files Browse the repository at this point in the history
A mahoosive PR to convert classes to use implicit usings, but no code changes
  • Loading branch information
RolandPheasant authored Mar 8, 2022
1 parent 456df89 commit b38c0d0
Show file tree
Hide file tree
Showing 458 changed files with 45,376 additions and 45,826 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ dotnet_diagnostic.SX1101.severity = error
dotnet_diagnostic.SX1309.severity = error

dotnet_diagnostic.SX1623.severity = none
dotnet_diagnostic.SX1309S.severity=silent

# C++ Files
[*.{cpp,h,in}]
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<RepositoryType>git</RepositoryType>
<PackageIcon>logo.png</PackageIcon>
<EnableNETAnalyzers>true</EnableNETAnalyzers>

<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
Expand Down
145 changes: 72 additions & 73 deletions src/DynamicData.Tests/AggregationTests/AggregationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,89 +9,88 @@

using Xunit;

namespace DynamicData.Tests.AggregationTests
{
public class AggregationFixture : IDisposable
{
private readonly IObservable<int> _accumulator;

private readonly SourceCache<Person, string> _source;
namespace DynamicData.Tests.AggregationTests;

/// <summary>
/// Initialises this instance.
/// </summary>
public AggregationFixture()
{
_source = new SourceCache<Person, string>(p => p.Name);

_accumulator = _source.Connect().ForAggregation().Scan(
0,
(current, items) =>
{
items.ForEach(
x =>
{
if (x.Type == AggregateType.Add)
{
current += x.Item.Age;
}
else
{
current -= x.Item.Age;
}
});
return current;
});
}
public class AggregationFixture : IDisposable
{
private readonly IObservable<int> _accumulator;

[Fact]
public void CanAccumulate()
{
int latest = 0;
int counter = 0;
private readonly SourceCache<Person, string> _source;

var accumulator = _accumulator.Subscribe(
value =>
/// <summary>
/// Initialises this instance.
/// </summary>
public AggregationFixture()
{
_source = new SourceCache<Person, string>(p => p.Name);

_accumulator = _source.Connect().ForAggregation().Scan(
0,
(current, items) =>
{
items.ForEach(
x =>
{
latest = value;
counter++;
if (x.Type == AggregateType.Add)
{
current += x.Item.Age;
}
else
{
current -= x.Item.Age;
}
});
return current;
});
}

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

counter.Should().Be(3, "Should be 3 updates");
latest.Should().Be(60, "Accumulated value should be 60");
_source.AddOrUpdate(new Person("A", 5));
[Fact]
public void CanAccumulate()
{
int latest = 0;
int counter = 0;

accumulator.Dispose();
}
var accumulator = _accumulator.Subscribe(
value =>
{
latest = value;
counter++;
});

[Fact]
public void CanHandleUpdatedItem()
{
int latest = 0;
int counter = 0;
_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

var accumulator = _accumulator.Subscribe(
value =>
{
latest = value;
counter++;
});
counter.Should().Be(3, "Should be 3 updates");
latest.Should().Be(60, "Accumulated value should be 60");
_source.AddOrUpdate(new Person("A", 5));

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("A", 15));
accumulator.Dispose();
}

counter.Should().Be(2, "Should be 2 updates");
latest.Should().Be(15, "Accumulated value should be 60");
accumulator.Dispose();
}
[Fact]
public void CanHandleUpdatedItem()
{
int latest = 0;
int counter = 0;

var accumulator = _accumulator.Subscribe(
value =>
{
latest = value;
counter++;
});

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("A", 15));

counter.Should().Be(2, "Should be 2 updates");
latest.Should().Be(15, "Accumulated value should be 60");
accumulator.Dispose();
}

public void Dispose()
{
_source.Dispose();
}
public void Dispose()
{
_source.Dispose();
}
}
}
101 changes: 50 additions & 51 deletions src/DynamicData.Tests/AggregationTests/AverageFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,73 @@

using Xunit;

namespace DynamicData.Tests.AggregationTests
namespace DynamicData.Tests.AggregationTests;

public class AverageFixture : IDisposable
{
public class AverageFixture : IDisposable
{
private readonly SourceCache<Person, string> _source;
private readonly SourceCache<Person, string> _source;

public AverageFixture()
{
_source = new SourceCache<Person, string>(p => p.Name);
}
public AverageFixture()
{
_source = new SourceCache<Person, string>(p => p.Name);
}

[Fact]
public void AddedItemsContributeToSum()
{
double avg = 0;
[Fact]
public void AddedItemsContributeToSum()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => p.Age).Subscribe(x => avg = x);
var accumulator = _source.Connect().Avg(p => p.Age).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));
_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(20, "Average value should be 20");
avg.Should().Be(20, "Average value should be 20");

accumulator.Dispose();
}
accumulator.Dispose();
}

public void Dispose()
{
_source.Dispose();
}
public void Dispose()
{
_source.Dispose();
}

[Fact]
public void InlineChangeReEvaluatesTotals()
{
double avg = 0;
[Fact]
public void InlineChangeReEvaluatesTotals()
{
double avg = 0;

var somepropChanged = _source.Connect().WhenValueChanged(p => p.Age);
var somepropChanged = _source.Connect().WhenValueChanged(p => p.Age);

var accumulator = _source.Connect().Avg(p => p.Age).InvalidateWhen(somepropChanged).Subscribe(x => avg = x);
var accumulator = _source.Connect().Avg(p => p.Age).InvalidateWhen(somepropChanged).Subscribe(x => avg = x);

var personb = new Person("B", 5);
_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(personb);
_source.AddOrUpdate(new Person("C", 30));
var personb = new Person("B", 5);
_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(personb);
_source.AddOrUpdate(new Person("C", 30));

avg.Should().Be(15, "Sum should be 15 after inline change");
avg.Should().Be(15, "Sum should be 15 after inline change");

personb.Age = 20;
personb.Age = 20;

avg.Should().Be(20, "Sum should be 20 after inline change");
accumulator.Dispose();
}
avg.Should().Be(20, "Sum should be 20 after inline change");
accumulator.Dispose();
}

[Fact]
public void RemoveProduceCorrectResult()
{
double avg = 0;
[Fact]
public void RemoveProduceCorrectResult()
{
double avg = 0;

var accumulator = _source.Connect().Avg(p => p.Age).Subscribe(x => avg = x);
var accumulator = _source.Connect().Avg(p => p.Age).Subscribe(x => avg = x);

_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));
_source.AddOrUpdate(new Person("A", 10));
_source.AddOrUpdate(new Person("B", 20));
_source.AddOrUpdate(new Person("C", 30));

_source.Remove("A");
avg.Should().Be(25, "Average value should be 25 after remove");
accumulator.Dispose();
}
_source.Remove("A");
avg.Should().Be(25, "Average value should be 25 after remove");
accumulator.Dispose();
}
}
}
Loading

0 comments on commit b38c0d0

Please sign in to comment.