예제 #1
0
            public void ThrowsWithoutMatch()
            {
                const string suiteName = "Services";
                const string appName   = "LoopNet";
                const string envName   = "TestMain";

                var suites = new List <Suite>
                {
                    new Suite {
                        SuiteName   = suiteName,
                        Application = new Application {
                            ApplicationName = appName
                        },
                        Environment = new Database.EntityFramework.Environment {
                            EnvironmentName = envName
                        },
                        SuiteID = 1
                    }
                };
                var mockSuites = suites.ToDbSetMock();

                mockSuites.Setup(m => m.AsNoTracking()).Returns(mockSuites.Object);

                var mockContext = new Mock <ZigNetEntities>();

                mockContext.Setup(m => m.Suites).Returns(mockSuites.Object);

                var zignetEntitiesWrapperMock = new Mock <IDbContext>();

                zignetEntitiesWrapperMock.Setup(z => z.Get()).Returns(mockContext.Object);

                var suiteService = new SuiteService(zignetEntitiesWrapperMock.Object);

                suiteService.GetId(appName, suiteName, "bad-env");
            }
예제 #2
0
        public async Task UpdateSuite_WhenFieldMoreThanMaxLengthValue_ShouldReturnBadRequest(
            string serializedSuite, string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var suiteModel   = SuiteFactory.GetSuiteModel();

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            var suite = await SuiteService.AddSuite(projectId, suiteModel);

            var suiteId          = SuiteSteps.GetSuiteId(suite);
            var updateSuiteModel = NewtonsoftJsonSerializer.DefaultDeserialize <RequestSuiteModel>(serializedSuite);

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, updateSuiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var errorResponse = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorResponse, typeOfError);
        }
예제 #3
0
        public async Task UpdateSuite_ShouldReturnOK()
        {
            //Arrange
            SetAuthorization();

            var suiteModel   = SuiteFactory.GetSuiteModel();
            var projectModel = ProjectFactory.GetProjectModel();

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            var suite = await SuiteService.AddSuite(projectId, suiteModel);

            var suiteId          = SuiteSteps.GetSuiteId(suite);
            var updateSuiteModel = SuiteFactory.GetSuiteModel();

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, updateSuiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var responseSuite = response.GetResponseSuiteModel();

            SuiteAssert.ValidateSuiteResult(updateSuiteModel, responseSuite);
        }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public BuildingViewModel(BuildingService buildingService, SuiteService suiteService)
 {
     BuildingServiceObj = buildingService;
     SuiteServiceObj    = suiteService;
     PopulateBuildingsDataGrid();
     SelectedBuilding       = new Building();
     _populateSuitesCommand = new DataGridSelectionChangedCommand(PopulateSuites, CanExecuteMethod);
 }
예제 #5
0
        protected BaseTest(ITestOutputHelper outputHelper)
        {
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .ClearProviders()
                .AddXUnit(outputHelper);
            });

            ClientExtended = ClientConfiguration.ConfigureHttpClient(loggerFactory);
            ProjectService = new ProjectService(ClientExtended);
            ProjectSteps   = new ProjectSteps(ProjectService);
            SuiteService   = new SuiteService(ClientExtended);
            SuiteSteps     = new SuiteSteps(SuiteService);
        }
예제 #6
0
        public async Task AddSuite_WhenSuiteIdHasIncorrectValue_ShouldReturnBadRequest(string projectId,
                                                                                       string typeOfError)
        {
            //Arrange
            SetAuthorization();
            var suiteModel = SuiteFactory.GetSuiteModel();

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

            //Arrange
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, typeOfError);
        }
예제 #7
0
        public async Task AddSuite_WhenUnauthorized_ShouldReturnUnauthorized()
        {
            //Arrange
            ClientExtended.ClearAuthorization();

            var       suiteModel = SuiteFactory.GetSuiteModel();
            const int projectId  = 123;

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, ErrorMessage.FailedAuthentication);
        }
예제 #8
0
        public async Task UpdateSuite_WhenNameHasIncorrectFormat_ShouldReturnBadRequest(string suiteId,
                                                                                        string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var suiteModel = SuiteFactory.GetSuiteModel();

            //Act
            var response = await SuiteService.UpdateSuite(suiteId, suiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var errorResponse = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(errorResponse, typeOfError);
        }
예제 #9
0
        protected BaseTest(ITestOutputHelper testOutputHelper)
        {
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .ClearProviders()
                .AddXUnit(testOutputHelper);
            });

            _client = new HttpClient(new LoggingHandler(new HttpClientHandler(), loggerFactory))
            {
                BaseAddress = new Uri(Startup.AppSettings.Services.TestRailApp.AppUrl)
            };

            _projectService = new ProjectService(_client);
            _projectSteps   = new ProjectSteps(_projectService);
            _suiteService   = new SuiteService(_client);
            _suiteSteps     = new SuiteSteps(_suiteService);
        }
예제 #10
0
            public void GetsWithName()
            {
                const string suiteName           = "Services";
                const string appNameAbbreviation = "LN";
                const string envNameAbbreviation = "TSM";

                var suites = new List <Suite>
                {
                    new Suite {
                        SuiteID     = 1,
                        SuiteName   = suiteName,
                        Application = new Application {
                            ApplicationNameAbbreviation = appNameAbbreviation
                        },
                        Environment = new Database.EntityFramework.Environment {
                            EnvironmentNameAbbreviation = envNameAbbreviation
                        }
                    }
                };
                var mockSuites = suites.ToDbSetMock();

                mockSuites.Setup(m => m.AsNoTracking()).Returns(mockSuites.Object);
                mockSuites.Setup(m => m.Include(It.IsAny <string>())).Returns(mockSuites.Object);

                var mockContext = new Mock <ZigNetEntities>();

                mockContext.Setup(m => m.Suites).Returns(mockSuites.Object);

                var zignetEntitiesWrapperMock = new Mock <IDbContext>();

                zignetEntitiesWrapperMock.Setup(z => z.Get()).Returns(mockContext.Object);

                var suiteService = new SuiteService(zignetEntitiesWrapperMock.Object);
                var suiteNameDto = suiteService.Get(1);

                Assert.AreEqual(suiteName, suiteNameDto.Name);
                Assert.AreEqual(appNameAbbreviation, suiteNameDto.ApplicationNameAbbreviation);
                Assert.AreEqual(envNameAbbreviation, suiteNameDto.EnvironmentNameAbbreviation);
            }
예제 #11
0
        public async Task AddSuite_WhenRequiredFieldHasIncorrectValue_ShouldReturnBadRequest(string serializedProject,
                                                                                             string typeOfError)
        {
            //Arrange
            SetAuthorization();

            var projectModel = ProjectFactory.GetProjectModel();
            var project      = await ProjectService.AddProject(projectModel);

            var projectId  = ProjectSteps.GetProjectId(project);
            var suiteModel = NewtonsoftJsonSerializer.DefaultDeserialize <RequestSuiteModel>(serializedProject);

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, typeOfError);
        }
예제 #12
0
        public async Task AddSuite_WhenProjectDoesNotExist_ShouldReturnBadRequest()
        {
            //Arrange
            SetAuthorization();

            var suiteModel   = SuiteFactory.GetSuiteModel();
            var projectModel = ProjectFactory.GetProjectModel();

            var project = await ProjectService.AddProject(projectModel);

            var projectId = ProjectSteps.GetProjectId(project);

            await ProjectService.DeleteProject(projectId);

            //Act
            var response = await SuiteService.AddSuite(projectId, suiteModel);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

            var responseMessage = response.GetErrors();

            ErrorAssert.ValidateErrorMessage(responseMessage, ErrorMessage.IncorrectProjectId);
        }
 public SuiteController(ISuiteRepository suiteRepositor, SuiteService suiteService, BookingContext contexto)
 {
     this.suiteRepository = suiteRepositor;
     this.suiteService    = suiteService;
     this.contexto        = contexto;
 }
예제 #14
0
 public SuiteSteps(SuiteService suiteService)
 {
     _suiteService = suiteService;
 }