public void Post_InvalidEnvironmentProd_ShouldReturnErrorAndResult() { // Arrange. var controller = new ComputersController(); controller.Request = HttpRequestHandler.GenerateHttpRequestMessage(); string serverName = TestConstants.NewComputerAccountProd; string environment = TestConstants.InvalidEnvironment; string projectName = TestConstants.ExistingOrganizationalUnitProd; string siteName = TestConstants.SitePrimary; var caRequest = new ComputerAccountRequest() { serverName = serverName, environment = environment, projectName = projectName, siteName = siteName }; var expected = ComputerAccountResultGenerator.GenerateResultForInvalidEnvironmentProd(); // Act. var result = controller.Post(TestConstants.checkpointAdminAcccessToken, caRequest); // Assert. Assert.IsNotNull(result); var caResult = result.Content.ReadAsAsync <ComputerAccountResult>().Result; Assert.AreEqual(expected.action, caResult.action); Assert.AreEqual(expected.message, caResult.message); Assert.AreEqual(expected.objectADPath, caResult.objectADPath); Assert.AreEqual(expected.serverName, caResult.serverName); }
public void Post_NewCAInNewOUTest_ShouldReturnSuccessAndResult() { // Arrange. var controller = new ComputersController(); controller.Request = HttpRequestHandler.GenerateHttpRequestMessage(); string serverName = TestConstants.NewComputerAccountTest; string environment = TestConstants.TestEnvironment; string projectName = TestConstants.NewOrganizationalUnitTest; string siteName = TestConstants.SitePrimary; var caRequest = new ComputerAccountRequest() { serverName = serverName, environment = environment, projectName = projectName, siteName = siteName }; var expected = ComputerAccountResultGenerator.GenerateResultForNewCAInTest(true, siteName); // Act. var result = controller.Post(TestConstants.checkpointAdminAcccessToken, caRequest); // Cleanup. ActiveDirectory.DeleteOrganizationalUnitTreeVoid(environment, projectName); // Assert. Assert.IsNotNull(result); var caResult = result.Content.ReadAsAsync <ComputerAccountResult>().Result; Assert.AreEqual(expected.action, caResult.action); Assert.AreEqual(expected.message, caResult.message); Assert.AreEqual(expected.objectADPath, caResult.objectADPath); Assert.AreEqual(expected.serverName, caResult.serverName); }