public void AdditionalFieldsControllerUpdateTest() { var type = CreateContext(); var fieldId = Guid.NewGuid(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); AdditionalField field = new AdditionalField() { Id = fieldId, Name = "First AdditionalField", Type = type, TypeId = type.Id, FieldType = "Texto" }; Logic.Create(field); AdditionalFieldDTO UpdatedField = new AdditionalFieldDTO() { Id = fieldId, Name = "Updated Field" }; var result = Controller.Put(fieldId, UpdatedField); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as AdditionalFieldDTO; Assert.AreEqual("Updated Field", model.Name); }
public void AdditionalFieldControllerPostTestWithRanges() { var id = Guid.NewGuid(); var type = CreateContext(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); var AdditionalField = new AdditionalField { Id = id, Name = "First AdditionalField", Type = type, TypeId = type.Id, FieldType = "Texto" }; FieldRange range = new FieldRange() { AdditionalFieldId = id, Range = "Range 1" }; FieldRange range2 = new FieldRange() { AdditionalFieldId = id, Range = "Range 2" }; FieldRange range3 = new FieldRange() { AdditionalFieldId = id, Range = "Range 3" }; var RangeList = new List <FieldRange>() { range, range2, range3 }; AdditionalField.Ranges = RangeList; var result = Controller.Post(AdditionalFieldDTO.ToModel(AdditionalField)); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as AdditionalFieldDTO; Assert.AreEqual(AdditionalField.Ranges.Count, model.Ranges.Count); }
public void TypesControllerDeleteTest() { var type = CreateContext(); var fieldId = Guid.NewGuid(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); AdditionalField field = new AdditionalField() { Id = fieldId, Name = "First AdditionalField", Type = type, TypeId = type.Id, FieldType = "Texto" }; Logic.Create(field); Controller.Delete(fieldId); Assert.ThrowsException <ExceptionController>(() => Logic.Get(fieldId)); }
public void AdditionalFieldControllerPostTest() { var type = CreateContext(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); var AdditionalField = new AdditionalField { Id = Guid.NewGuid(), Name = "First AdditionalField", Type = type, TypeId = type.Id, FieldType = "Entero" }; FieldRange dummyRangeStart = new FieldRange() { AdditionalFieldId = AdditionalField.Id, Range = "1" }; FieldRange dummyRangeEnd = new FieldRange() { AdditionalFieldId = AdditionalField.Id, Range = "10" }; var DummyIntRangeList = new List <FieldRange>() { dummyRangeStart, dummyRangeEnd }; AdditionalField.Ranges = DummyIntRangeList; var result = Controller.Post(AdditionalFieldDTO.ToModel(AdditionalField)); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as AdditionalFieldDTO; Assert.AreEqual(AdditionalField.Name, model.Name); }
public void AdditionalFieldsControllerGetTest() { var type = CreateContext(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); var Field = new AdditionalField { Id = Guid.NewGuid(), Name = "First Field", Type = type, TypeId = type.Id, FieldType = "Texto" }; Logic.Create(Field); var Result = Controller.Get(Field.Id); var CreatedResult = Result as OkObjectResult; var Model = CreatedResult.Value as AdditionalFieldDTO; Assert.AreEqual(Field.Name, Model.Name); }
public void AdditionalFieldsControllerGetAllTest() { var type = CreateContext(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); var FirstAdditionalField = new AdditionalField { Id = Guid.NewGuid(), Name = "First Field", Type = type, FieldType = "Texto", TypeId = type.Id }; var SecondAdditionalField = new AdditionalField { Id = Guid.NewGuid(), Name = "Second Field", Type = type, FieldType = "Texto", TypeId = type.Id }; Logic.Create(FirstAdditionalField); Logic.Create(SecondAdditionalField); List <AdditionalField> AdditionalFields = new List <AdditionalField>() { FirstAdditionalField, SecondAdditionalField }; var Result = Controller.Get(); var CreatedResult = Result as OkObjectResult; var FieldResults = CreatedResult.Value as IEnumerable <AdditionalFieldDTO>; Assert.AreEqual(AdditionalFields.Count, FieldResults.ToList().Count); }
public void AdditionalFieldsControllerGetTest2() { var type = CreateContext(); var Logic = CreateLogic(); var Controller = new AdditionalFieldsController(Logic); var FirstField = new AdditionalField { Id = Guid.NewGuid(), Name = "First Field", Type = type, TypeId = type.Id, FieldType = "Fecha" }; var SecondField = new AdditionalField { Id = Guid.NewGuid(), Name = "Second Field", Type = type, TypeId = type.Id, FieldType = "Entero" }; FieldRange dummyRangeStartDate = new FieldRange() { AdditionalFieldId = FirstField.Id, Range = "01/14/1993" }; FieldRange dummyRangeEndDate = new FieldRange() { AdditionalFieldId = FirstField.Id, Range = "01/30/1993" }; FieldRange dummyRangeStart = new FieldRange() { AdditionalFieldId = SecondField.Id, Range = "1" }; FieldRange dummyRangeEnd = new FieldRange() { AdditionalFieldId = SecondField.Id, Range = "10" }; var DummyIntRangeList = new List <FieldRange>() { dummyRangeStart, dummyRangeEnd }; var DummyDateRangeList = new List <FieldRange>() { dummyRangeStartDate, dummyRangeEndDate }; FirstField.Ranges = DummyDateRangeList; SecondField.Ranges = DummyIntRangeList; Logic.Create(FirstField); Logic.Create(SecondField); var Result = Controller.Get(SecondField.Id); var CreatedResult = Result as OkObjectResult; var Model = CreatedResult.Value as AdditionalFieldDTO; Assert.AreEqual(SecondField.Name, Model.Name); }