Ejemplo n.º 1
0
        public void ChargeSaved_LastStatusSet_OnStatusChange(ChargingStatus newStatus)
        {
            // Arrange
            var logger = new Mock <ILogger>();
            var durableOrchestrationContextMock = new TestDurableOrchestrationContext();

            durableOrchestrationContextMock.ReturnChargeState = new ChargeState()
            {
                ChargingState = newStatus
            };
            durableOrchestrationContextMock.ReturnOrchestrationData = new OrchestrationData();
            durableOrchestrationContextMock.ReturnChargingStatus    = ChargingStatus.Charging;

            // Act
            //var result = CheckChargeStatus.RunOrchestrator(durableOrchestrationContextMock, logger.Object);

            ArrayList saveChargeApiCalls = new ArrayList();

            durableOrchestrationContextMock.CallActivityCalls.TryGetValue("SaveCharge", out saveChargeApiCalls);
            Assert.Single(saveChargeApiCalls);

            ArrayList setChargingStatusCalls = new ArrayList();

            durableOrchestrationContextMock.SignalEntityCalls.TryGetValue("ChargingStatus_Set", out setChargingStatusCalls);
            Assert.Single(setChargingStatusCalls);
            Assert.Equal(newStatus, setChargingStatusCalls[0]);
        }
Ejemplo n.º 2
0
        public void CorrectChargeAmountSaved_OnStatusChange(ChargingStatus newStatus)
        {
            // Arrange
            var logger = new Mock <ILogger>();
            var durableOrchestrationContextMock = new TestDurableOrchestrationContext();

            durableOrchestrationContextMock.ReturnChargeState = new ChargeState()
            {
                ChargingState = newStatus, ChargeEnergyAdded = 18.99m
            };
            durableOrchestrationContextMock.ReturnOrchestrationData = new OrchestrationData();
            durableOrchestrationContextMock.ReturnChargingStatus    = ChargingStatus.Charging;

            // Act
            //gularDockervar result = CheckChargeStatus.RunOrchestrator(durableOrchestrationContextMock, logger.Object);

            ArrayList saveChargeApiCalls = new ArrayList();

            durableOrchestrationContextMock.CallActivityCalls.TryGetValue("SaveCharge", out saveChargeApiCalls);
            var charge = saveChargeApiCalls[0] as ChargeState;

            Assert.Equal(18.99m, charge.ChargeEnergyAdded);
        }