public void Constructor_InitializesPropertiesProperly() { string appName = "SomeName"; string envirometnName = "SomeEnviroment"; string regionName = "SomeRegion"; string clusterName = "SomeClusterName"; Environment.SetEnvironmentVariable("REGION_NAME", regionName); Environment.SetEnvironmentVariable("CLUSTER_NAME", clusterName); Mock <IHostEnvironment> enviromentMock = new Mock <IHostEnvironment>(); enviromentMock.SetupGet(e => e.ApplicationName).Returns(appName); enviromentMock.SetupGet(e => e.EnvironmentName).Returns(envirometnName); Accessor <StatelessServiceContext> accessor = new Accessor <StatelessServiceContext>(); IAccessorSetter <StatelessServiceContext> setter = accessor; IExecutionContext info = new ServiceFabricExecutionContext(enviromentMock.Object, accessor); setter.SetContext(MockStatelessServiceContextFactory.Default); Assert.AreEqual(appName, info.ServiceName); Assert.AreEqual(envirometnName, info.EnvironmentName); Assert.AreEqual(regionName, info.RegionName); Assert.AreEqual(clusterName, info.Cluster); }
public void Constructor_InitializesPropertiesProperly() { ServiceContext context = MockStatelessServiceContextFactory.Default; Accessor <ServiceContext> accessor = new Accessor <ServiceContext>(); ((IAccessorSetter <ServiceContext>)accessor).SetValue(context); IExecutionContext info = new ServiceFabricExecutionContext(new Mock <IHostEnvironment>().Object, accessor); Assert.AreEqual(context.CodePackageActivationContext.CodePackageVersion, info.BuildVersion); }