Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add
ServiceExtensions.GetPartition
and SetPartition
for alexmar…
…shall132.
- Loading branch information
Showing
8 changed files
with
234 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using System.Fabric; | ||
using System.Fabric.Health; | ||
|
||
namespace ServiceFabric.Mocks | ||
{ | ||
/// <inheritdoc /> | ||
public class MockStatefulServicePartition : IStatefulServicePartition | ||
{ | ||
/// <inheritdoc /> | ||
public PartitionAccessStatus ReadStatus { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public PartitionAccessStatus WriteStatus { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public ServicePartitionInformation PartitionInfo { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public void ReportLoad(IEnumerable<LoadMetric> metrics) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportFault(FaultType faultType) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportMoveCost(MoveCost moveCost) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportPartitionHealth(HealthInformation healthInfo) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportPartitionHealth(HealthInformation healthInfo, HealthReportSendOptions sendOptions) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public FabricReplicator CreateReplicator(IStateProvider stateProvider, ReplicatorSettings replicatorSettings) | ||
{ | ||
return null; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportReplicaHealth(HealthInformation healthInfo) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportReplicaHealth(HealthInformation healthInfo, HealthReportSendOptions sendOptions) | ||
{ | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections.Generic; | ||
using System.Fabric; | ||
using System.Fabric.Health; | ||
|
||
namespace ServiceFabric.Mocks | ||
{ | ||
/// <inheritdoc /> | ||
public class MockStatelessServicePartition : IStatelessServicePartition | ||
{ | ||
/// <inheritdoc /> | ||
public void ReportLoad(IEnumerable<LoadMetric> metrics) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportFault(FaultType faultType) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportMoveCost(MoveCost moveCost) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportPartitionHealth(HealthInformation healthInfo) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportPartitionHealth(HealthInformation healthInfo, HealthReportSendOptions sendOptions) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public ServicePartitionInformation PartitionInfo { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public void ReportInstanceHealth(HealthInformation healthInfo) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void ReportInstanceHealth(HealthInformation healthInfo, HealthReportSendOptions sendOptions) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 30 additions & 29 deletions
59
test/ServiceFabric.Mocks.Tests/MocksTests/MockStatefulServiceContextFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Fabric; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using ServiceFabric.Mocks.Tests.Services; | ||
|
||
namespace ServiceFabric.Mocks.Tests.MocksTests | ||
{ | ||
[TestClass] | ||
[TestClass] | ||
public class MockStatefulServiceContextFactoryTests | ||
{ | ||
[TestMethod] | ||
public void TestDefaultServiceUri() | ||
{ | ||
var instance = MockStatefulServiceContextFactory.Default; | ||
[TestMethod] | ||
public void TestDefaultServiceUri() | ||
{ | ||
var instance = MockStatefulServiceContextFactory.Default; | ||
|
||
Assert.IsInstanceOfType(instance, typeof(StatefulServiceContext)); | ||
Assert.AreEqual(new Uri(MockStatefulServiceContextFactory.ServiceName), instance.ServiceName); | ||
Assert.AreEqual(MockStatefulServiceContextFactory.ServiceTypeName, instance.ServiceTypeName); | ||
} | ||
Assert.IsInstanceOfType(instance, typeof(StatefulServiceContext)); | ||
Assert.AreEqual(new Uri(MockStatefulServiceContextFactory.ServiceName), instance.ServiceName); | ||
Assert.AreEqual(MockStatefulServiceContextFactory.ServiceTypeName, instance.ServiceTypeName); | ||
} | ||
|
||
[TestMethod] | ||
public void TestCustom() | ||
{ | ||
var newUri = new Uri("fabric:/MockApp/OtherMockStatefulService"); | ||
var serviceTypeName = "OtherMockServiceType"; | ||
var partitionId = Guid.NewGuid(); | ||
var replicaId = long.MaxValue; | ||
var context = new MockCodePackageActivationContext("fabric:/MyApp", "MyAppType", "Code", "Ver", "Context", "Log", "Temp", "Work", "Man", "ManVer"); | ||
[TestMethod] | ||
public void TestCustom() | ||
{ | ||
var newUri = new Uri("fabric:/MockApp/OtherMockStatefulService"); | ||
var serviceTypeName = "OtherMockServiceType"; | ||
var partitionId = Guid.NewGuid(); | ||
var replicaId = long.MaxValue; | ||
var context = new MockCodePackageActivationContext("fabric:/MyApp", "MyAppType", "Code", "Ver", "Context", "Log", "Temp", "Work", "Man", "ManVer"); | ||
|
||
var instance = MockStatefulServiceContextFactory.Create(context, serviceTypeName, newUri, partitionId, replicaId); | ||
var instance = MockStatefulServiceContextFactory.Create(context, serviceTypeName, newUri, partitionId, replicaId); | ||
|
||
Assert.IsInstanceOfType(instance, typeof(StatefulServiceContext)); | ||
Assert.AreEqual(context, instance.CodePackageActivationContext); | ||
Assert.AreEqual(newUri, instance.ServiceName); | ||
Assert.AreEqual(serviceTypeName, instance.ServiceTypeName); | ||
Assert.AreEqual(partitionId, instance.PartitionId); | ||
Assert.AreEqual(replicaId, instance.ReplicaId); | ||
Assert.AreEqual(replicaId, instance.ReplicaOrInstanceId); | ||
} | ||
} | ||
Assert.IsInstanceOfType(instance, typeof(StatefulServiceContext)); | ||
Assert.AreEqual(context, instance.CodePackageActivationContext); | ||
Assert.AreEqual(newUri, instance.ServiceName); | ||
Assert.AreEqual(serviceTypeName, instance.ServiceTypeName); | ||
Assert.AreEqual(partitionId, instance.PartitionId); | ||
Assert.AreEqual(replicaId, instance.ReplicaId); | ||
Assert.AreEqual(replicaId, instance.ReplicaOrInstanceId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters