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"); }
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); }
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); }
/// <summary> /// Constructor /// </summary> public BuildingViewModel(BuildingService buildingService, SuiteService suiteService) { BuildingServiceObj = buildingService; SuiteServiceObj = suiteService; PopulateBuildingsDataGrid(); SelectedBuilding = new Building(); _populateSuitesCommand = new DataGridSelectionChangedCommand(PopulateSuites, CanExecuteMethod); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
public SuiteSteps(SuiteService suiteService) { _suiteService = suiteService; }