Пример #1
0
        public async void ServerModule_ServerStartFail_ReturnsFailMessage()
        {
            const string expectedMessage = "Server 'test' error: Test Error Message";
            var          mockedRequester = new Mock <IServerRequester>();
            var          failStartResult =
                new ServerStartStopResult {
                Error = true, ErrorMessage = "Test Error Message", Id = "test", Port = 1234
            };

            mockedRequester.Setup(x => x.SendStartRequestAsync("test", 1234)).ReturnsAsync(failStartResult);

            var serverModule = new ServerModuleWrapper(mockedRequester.Object);
            await serverModule.StartServerAsync("test", 1234);

            Assert.Equal(expectedMessage, serverModule.LastMessage);
        }
Пример #2
0
        public async void ServerModule_ServerStopSuccess_ReturnsSuccessMessage()
        {
            const string expectedMessage   = "Server 'test': Server stopped.";
            var          mockedRequester   = new Mock <IServerRequester>();
            var          successStopResult =
                new ServerStartStopResult {
                Error = false, Id = "test", Message = "Server stopped.", Port = 1234
            };

            mockedRequester.Setup(x => x.SendStopRequestAsync("test")).ReturnsAsync(successStopResult);

            var serverModule = new ServerModuleWrapper(mockedRequester.Object);
            await serverModule.StopServerAsync("test");

            Assert.Equal(expectedMessage, serverModule.LastMessage);
        }
Пример #3
0
        public async void ServerModule_ServerUpdateFail_ReturnsFailMessage()
        {
            const string expectedMessage  = "Update request for \"test\" is finished. Got error: ERROR.";
            var          failUpdateResult = new UpdateResult()
            {
                Error = true, ErrorMessage = "ERROR."
            };
            var mockedRequester = new Mock <IServerRequester>();

            mockedRequester.Setup(x => x.SendUpdateRequestAsync("test", "master", "")).ReturnsAsync(failUpdateResult);

            var serverModule = new ServerModuleWrapper(mockedRequester.Object);
            await serverModule.UpdateServerAsync("test");

            Assert.Equal(expectedMessage, serverModule.LastMessage);
        }
Пример #4
0
        public async void ServerModule_ServerUpdateNotUpToDate_ReturnsSuccessMessage()
        {
            const string expectedMessage =
                "Server \"test\" was compiled on branch \"test-branch\" and on commit \"aaabbbccc\" (Test commit).\nBuild log:\nOUTPUT";
            var mockedRequester     = new Mock <IServerRequester>();
            var successUpdateResult = new UpdateResult()
            {
                Branch        = "test-branch",
                CommitHash    = "aaabbbccc",
                CommitMessage = "Test commit",
                Id            = "test",
                Output        = "OUTPUT"
            };

            mockedRequester.Setup(x => x.SendUpdateRequestAsync("test", "master", "")).ReturnsAsync(successUpdateResult);

            var serverModule = new ServerModuleWrapper(mockedRequester.Object);
            await serverModule.UpdateServerAsync("test");

            Assert.Equal(expectedMessage, serverModule.LastMessage);
        }
Пример #5
0
        public async void ServerModule_ServerUpdateUpToDate_ReturnsSuccessMessage()
        {
            const string expectedMessage =
                "Update request for \"test\" is finished." +
                " Server is up-to-date on branch \"test-branch\" and on commit \"aaabbbccc\" (Test commit).";
            var mockedRequester     = new Mock <IServerRequester>();
            var successUpdateResult = new UpdateResult()
            {
                Branch        = "test-branch",
                CommitHash    = "aaabbbccc",
                CommitMessage = "Test commit",
                Id            = "test",
                UpToDate      = true
            };

            mockedRequester.Setup(x => x.SendUpdateRequestAsync("test", "master", "")).ReturnsAsync(successUpdateResult);

            var serverModule = new ServerModuleWrapper(mockedRequester.Object);
            await serverModule.UpdateServerAsync("test");

            Assert.Equal(expectedMessage, serverModule.LastMessage);
        }