public void LoginAdminIB(string login, string pass, int statusCodeExpectedResult) { //Логинимся под AdminTest Name = "AdminIb"; JsonSchema validSchema = SchemaConstructorInt.SchemaGeneratorForLogin(); RequestHelperInt.pRequestLoginAdminIB.AddJsonBody(new { Login = login, Password = pass }); response = AuthInt.Client.Execute(RequestHelperInt.pRequestLoginAdminIB); statusCode = response.StatusCode; int numericStatusCode = (int)statusCode; var assertsAccumulator = new AssertAccumulatorInt(); try { responseJson = JObject.Parse(response.Content); message = ResponseHelperInt.ReturnMessage(responseJson); } catch { JObject badContent = ResponseHelperInt.ReturnBadRequestAnswer(response.Content); //Проверка на статус код assertsAccumulator.Accumulate( () => Assert.That(numericStatusCode, Is.EqualTo(statusCodeExpectedResult), $"StatusCode: {numericStatusCode} - is not OK\n{badContent.ToString()}")); assertsAccumulator.Release(); } //Проверка на валидность схемы ответа assertsAccumulator.Accumulate( () => Assert.That(responseJson.IsValid(validSchema), "Schema is invalid")); //Проверка на статус код assertsAccumulator.Accumulate( () => Assert.That(numericStatusCode, Is.EqualTo(statusCodeExpectedResult), $"StatusCode: {numericStatusCode} - is not OK\n" + message)); assertsAccumulator.Release(); //Проверка что залогинились под AdminTest string firstName = responseJson["data"]["User"]["Roles"][0].ToString(); assertsAccumulator.Accumulate( () => Assert.That(firstName, Is.EqualTo(Name), $"FirstName {firstName} is invalid")); }
public void Logout(int statusCodeExpectedResult) { AuthInt.GetToken(); AuthToken = AuthInt.token; JsonSchema validSchema = SchemaConstructorInt.SchemaGeneratorForLogout(); //Добавляем токен авторизации в хедер AddParamsInt.AddAuthTokenInRequestHeader(RequestHelperInt.pRequestLogout); response = AuthInt.Client.Execute(RequestHelperInt.pRequestLogout); statusCode = response.StatusCode; int numericStatusCode = (int)statusCode; var assertsAccumulator = new AssertAccumulatorInt(); try { responseJson = JObject.Parse(response.Content); message = ResponseHelperInt.ReturnMessage(responseJson); } catch { JObject badContent = ResponseHelperInt.ReturnBadRequestAnswer(response.Content); //Проверка на статус код assertsAccumulator.Accumulate( () => Assert.That(numericStatusCode, Is.EqualTo(statusCodeExpectedResult), $"StatusCode: {numericStatusCode} - is not OK\n{badContent.ToString()}")); assertsAccumulator.Release(); } ////Проверка на валидность схемы ответа assertsAccumulator.Accumulate( () => Assert.IsTrue(responseJson.IsValid(validSchema), "Schema is incorrect")); //Проверка на статус код assertsAccumulator.Accumulate( () => Assert.That(numericStatusCode, Is.EqualTo(statusCodeExpectedResult), $"StatusCode: {numericStatusCode} - is not OK\n" + message)); assertsAccumulator.Release(); }