Пример #1
0
        public async Task GetNextState_FromRunDockerComposeOnInstanceState_ReturnsNull()
        {
            //Arrange
            var flow = new DeployToClusterStateFlow(
                "127.0.0.1",
                new[]
            {
                "some-docker-compose-contents"
            });

            var serviceProvider = TestServiceProviderFactory.CreateUsingStartup();
            var stateFactory    = new ProvisioningStateFactory(serviceProvider);

            var fakeState    = Substitute.For <IRunDockerComposeOnInstanceState>();
            var fakeMediator = Substitute.For <IMediator>();

            //Act
            var state = await flow.GetNextStateAsync(new NextStateContext(
                                                         fakeMediator,
                                                         stateFactory,
                                                         fakeState));

            //Assert
            Assert.IsNull(state);
        }
Пример #2
0
        public async Task GetInitialState_ValuesGiven_TransfersValuesToInitialState()
        {
            //Arrange
            var buildArguments = new Dictionary <string, string>();

            var flow = new DeployToClusterStateFlow(
                "127.0.0.1",
                new[]
            {
                "some-docker-compose-contents"
            })
            {
                BuildArguments = buildArguments
            };

            var serviceProvider = TestServiceProviderFactory.CreateUsingStartup();
            var stateFactory    = new ProvisioningStateFactory(serviceProvider);

            var fakeMediator = Substitute.For <IMediator>();

            fakeMediator
            .Send(Arg.Any <GetLightsailInstanceByNameQuery>())
            .Returns(new Instance()
            {
                PublicIpAddress = "127.0.0.1"
            });

            //Act
            var state = await flow.GetInitialStateAsync(new InitialStateContext(
                                                            fakeMediator,
                                                            stateFactory)) as IRunDockerComposeOnInstanceState;

            //Assert
            Assert.IsNotNull(state);

            Assert.AreEqual("127.0.0.1", state.IpAddress);
            Assert.AreEqual("some-docker-compose-contents", state.DockerComposeYmlFilePaths?.Single());

            Assert.AreSame(buildArguments, state.BuildArguments);
        }