Example #1
0
        public void ThenCollectorIsSavedCorrectly()
        {
            Collector expectedObject = ContextExpectedCollector;
            Collector actualObject   = GetCollectorDataById("last");

            Assert.AreEqual(expectedObject, actualObject, PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #2
0
 public void ThenStudentIsModifiedCorrectly(string id)
 {
     Student expectedObject = ScenarioContext.Get<Student>("expectedModifiedStudent");
     Student actualObject = GetStudentDataById(id);
     Assert.AreEqual(expectedObject, actualObject, 
         PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
 }
Example #3
0
 public void ThenStudentIsSavedCorrectly()
 {
     Student expectedObject = ContextExpectedStudent;
     Student actualObject = GetStudentDataById("last");
     Assert.AreEqual(expectedObject, actualObject,
         PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
 }
Example #4
0
        public void ThenDebtIsSavedCorrectly()
        {
            Debt expectedObject = ContextExpectedDebt;
            Debt actualObject   = GetDebtDataById("last");

            Assert.AreEqual(expectedObject, actualObject,
                            PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #5
0
        public void ThenAppointmentDataIsSavedCorrectly()
        {
            Appointment actualObject   = GetAppointmentDataById("last");
            Appointment expectedObject = ContextExpectedAppointment;

            Assert.AreEqual(expectedObject, actualObject,
                            PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #6
0
 public void AddStudentWithParameters(StudentCreator student)
 {
     new StudentSteps().CreateStudent(student);
     Student expectedStudent = Transformations.GetStudentBasedOnStudentCreator(student);
     ScenarioContext.Set(expectedStudent, ExpectedStudent);
     Logger.Info($"\nStudent created with the following properties. " +
         $"{PropertiesDescriber.GetObjectProperties(expectedStudent)}");
 }
Example #7
0
 public void CheckStudentPresenceInList()
 {
     var actualObjectsList = new List<object>();
     Student expectedObject = ContextExpectedStudent;
     new StudentSteps().GetListOfStudents().ForEach(element => actualObjectsList.Add(element));
     Assert.Contains(expectedObject, actualObjectsList,
         PropertiesDescriber.GetActualObjectsListAndExpectedObjectProperties(expectedObject, actualObjectsList));
 }
Example #8
0
        public void ThenCollectorIsModifiedCorrectly(string id)
        {
            Collector expectedObject = ScenarioContext.Get <Collector>("expectedModifiedCollector");
            Collector actualObject   = GetCollectorDataById(id);

            Assert.AreEqual(expectedObject, actualObject,
                            PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #9
0
        public void AddDebtWithParameters(DebtCreator debt)
        {
            new DebtSteps().CreateDebt(debt);
            Debt expectedDebt = Transformations.GetDebtBasedOnDebtCreator(debt);

            ScenarioContext.Set(expectedDebt, ExpectedDebt);
            Logger.Info($"\nDebt created with the following properties. " +
                        $"{PropertiesDescriber.GetObjectProperties(expectedDebt)}");
        }
Example #10
0
        public void CheckCollectorPresenceInList()
        {
            var       actualObjectsList = new List <object>();
            Collector expectedObject    = ContextExpectedCollector;

            new CollectorSteps().GetListOfCollectors().ForEach(element => actualObjectsList.Add(element));
            Assert.Contains(expectedObject, actualObjectsList,
                            PropertiesDescriber.GetActualObjectsListAndExpectedObjectProperties(expectedObject, actualObjectsList));
        }
Example #11
0
        public void AddCollectorWithParameters(CollectorCreator collector)
        {
            new CollectorSteps().CreateCollector(collector);
            Collector expectedCollector = Transformations.GetCollectorBasedOnCollectorCreator(collector);

            ScenarioContext.Set(expectedCollector, ExpectedCollector);
            Logger.Info($"\nCollector created with the following properties. " +
                        $"{PropertiesDescriber.GetObjectProperties(expectedCollector)}");
        }
Example #12
0
        public void AddAppointmentWithParameters(AppointmentCreator appointment)
        {
            new AppointmentSteps().CreateAppointment(appointment);
            Appointment expectedAppointment = Transformations.GetAppointmentBasedOnAppointmentCreator(appointment);

            ScenarioContext.Set(expectedAppointment, ExpectedAppointment);
            Logger.Info($"\nAppointment created with the following properties. " +
                        $"{PropertiesDescriber.GetObjectProperties(expectedAppointment)}");
        }
Example #13
0
        public void FindCollectorByParameters(CollectorCreator expectedCollector)
        {
            int countOfObjects = new CollectorSteps().GetListOfCollectors()
                                 .Count(collector => collector.fearFactor.Equals(expectedCollector.fearFactor) &&
                                        collector.nickname.Equals(expectedCollector.nickname));

            Assert.AreEqual(1, countOfObjects,
                            $"There should be only one collector with the following properties. Actual count of such collectors is {countOfObjects}." +
                            $"{PropertiesDescriber.GetObjectProperties(expectedCollector)}");
        }
Example #14
0
 public void FindStudentByParameters(StudentCreator expectedStudent)
 {
     int countOfObjects = new StudentSteps().GetListOfStudents()
         .Count(student => student.name.Equals(expectedStudent.name)
         && student.age.Equals(expectedStudent.age)
         && student.sex.Equals(expectedStudent.sex)
         && student.risk.Equals(expectedStudent.risk));
     Assert.AreEqual(1, countOfObjects,
         $"There should be only one student with the following properties. Actual count of such students is {countOfObjects}." +
         $"{PropertiesDescriber.GetObjectProperties(expectedStudent)}");
 }
Example #15
0
        public void ThenDebtWithIdIsConnectedWithFollowingObject(string id, SdcaParts sdcaPart, Table table)
        {
            int    neededId       = GetNeededId(id, SdcaParts.debt);
            object expectedObject = sdcaPart switch
            {
                SdcaParts.student => Transformations.GetStudentBasedOnStudentCreator(StepArgumentTransformations.GetStudentCreator(table)),
                _ => null
            };
            object actualObject = sdcaPart switch
            {
                SdcaParts.student => new StudentSteps().GetStudentById(new DebtSteps().GetDebtById(neededId).studentId),
                _ => null
            };

            Assert.AreEqual(expectedObject, actualObject,
                            PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #16
0
        public void ThenAppointmentDataWithIdIsConnectedWithFollowingObject(string id, SdcaParts sdcaPart, Table table)
        {
            int    neededId       = GetNeededId(id, SdcaParts.appointment);
            object expectedObject = sdcaPart switch
            {
                SdcaParts.debt => Transformations.GetDebtBasedOnDebtCreator(StepArgumentTransformations.GetDebtCreator(table)),
                SdcaParts.collector => Transformations.GetCollectorBasedOnCollectorCreator(StepArgumentTransformations.GetCollectorCreator(table)),
                _ => null
            };
            Appointment appointment  = new AppointmentSteps().GetAppointmentById(neededId);
            object      actualObject = sdcaPart switch
            {
                SdcaParts.debt => new DebtSteps().GetDebtById(appointment.debtId),
                SdcaParts.collector => new CollectorSteps().GetCollectorById(appointment.collectorIds[0]),
                _ => null
            };

            Assert.AreEqual(expectedObject, actualObject,
                            PropertiesDescriber.GetActualAndExpectedObjectsProperties(expectedObject, actualObject));
        }
Example #17
0
        private IRestResponse ExecuteRequest(Method method, HttpStatusCode expectedStatusCode, object body = null, string objectId = "")
        {
            var         resourceUrl = $"{Resource}/{objectId}";
            RestRequest restRequest = new RestRequest(resourceUrl, method);

            restRequest.RequestFormat = DataFormat.Json;
            Logger.Debug($"\nTrying send a request for url {BaseUrl}{resourceUrl}." +
                         $"\nMethod: {method}");
            if (body != null)
            {
                restRequest.AddJsonBody(body);
                Logger.Debug($"\nBody: {PropertiesDescriber.GetObjectProperties(body)}");
            }
            IRestResponse response = RestClient.Execute(restRequest);

            if (expectedStatusCode != 0)
            {
                CheckHttpStatusCode(response, expectedStatusCode);
            }
            Logger.Debug($"\nResponse status code: {response.StatusCode}");
            return(response);
        }