public void MergeTest() { //TODO: дописать тесты для вопросов BaseResultType error = new BaseResultType(); error.Status = ResultStatus.Fail; error.AddError("Error"); BaseResultType message = new BaseResultType(); message.Status = ResultStatus.Success; message.AddMessage("Message"); //При merge, IsSuccess не должен изменяться из fail в success, но должен меняться из success в fail. Если была ошибка, то ошибка должна остаться error.Merge(message); Assert.AreEqual(ResultStatus.Fail, error.Status); Assert.AreEqual("Error" + Environment.NewLine + "Message", error.Message); error.Message = "Error";//Сьрасываем сообщение на исходное message.Merge(error); Assert.AreEqual(ResultStatus.Fail, error.Status); Assert.AreEqual("Message" + Environment.NewLine + "Error", message.Message); }
public void MergeQuestionTest() { BaseResultType withQuestion = new BaseResultType(); withQuestion.AddWarring(new WarningQuestion()); BaseResultType withoutQuestion = new BaseResultType(); withQuestion.Merge(withoutQuestion); Assert.IsNotNull(withQuestion.Question); Assert.AreEqual(1, withQuestion.Question.Count); withoutQuestion.Merge(withoutQuestion); Assert.IsNotNull(withQuestion.Question); Assert.AreEqual(1, withQuestion.Question.Count); //Мерж с пустыми списками вопросов withQuestion = new BaseResultType(); withoutQuestion = new BaseResultType(); withoutQuestion.Merge(withoutQuestion); Assert.IsNotNull(withoutQuestion.Question); Assert.AreEqual(0, withoutQuestion.Question.Count); }