public void ClassifierWithSystemTypes_ConvertFromDto_MissingSystemTypesAreAdded() { _classifiers = new ClassifierDictionary(); // act: convert dtos to classifier types _converter = new DomainDtoConverter(); _converter.ToDomain(new Diagram(_classifiers),new DiagramDataDto {Classifiers = new List<ClassifierDto>()}); Assert.AreEqual(new SystemTypes().Count(), _classifiers.Count); }
public void LoadSystemTypes_AddMissingSystemTypes() { // Arrange var dtos = new List<ClassifierDto> { StringDto }; var converter = new DomainDtoConverter(); // Act converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos }); // Assert => one system type was loaded, the other ones should be added automatically Assert.AreEqual(new SystemTypes().Count(),_classifierDictionary.Count); }
public void Classifiers_ConvertToDto_KeepReferences() { // Arrange var dtos = new List<ClassifierDto> { StringDto, IntegerDto }; var converter = new DomainDtoConverter(); // Act converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto {Classifiers = dtos}); // ensure that properties use the same object references // as the classifier dictionary Assert.AreEqual( _classifierDictionary.ElementAt(0), _classifierDictionary.ElementAt(1).Properties.ElementAt(0).Type); Assert.AreEqual(_classifierDictionary.ElementAt(1), _classifierDictionary.ElementAt(0).Properties.ElementAt(0).Type); }
public void LoadClassifiers_SystemTypeReferences_AreCorrect() { const string classifierName = "ClassifierWithSystemType"; // Arrange var dtoWithSystemTypeProperty = new ClassifierDto { Name = classifierName, Properties = new List<PropertyDto>{new PropertyDto {Name = "Property", Type = StringDto}} }; var dtos = new List<ClassifierDto> { dtoWithSystemTypeProperty,StringDto }; var converter = new DomainDtoConverter(); // Act converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos }); // Assert => ensure that the instance of String is always the same in the dictionary Assert.AreEqual( _classifierDictionary.String, _classifierDictionary.FindByName(classifierName).Properties.Single().Type); }
public void Methods_ConvertToDtoAndDomain() { // Arrange var dtos = new List<ClassifierDto> {VoidDto, StringDto, ServiceDto}; var converter = new DomainDtoConverter(); // Act converter.ToDomain(new Diagram(_classifierDictionary), new DiagramDataDto { Classifiers = dtos }); // Assert return type has correct reference Assert.AreEqual( _classifierDictionary.Void, _classifierDictionary .FindByName(Service.Name) .Methods.ElementAt(0).ReturnType); // Assert parameters have correct reference Assert.AreEqual( _classifierDictionary.String, _classifierDictionary .FindByName(Service.Name) .Methods.ElementAt(0) .Parameters.ElementAt(0).Type); }
protected override void Init() { _converter = new DomainDtoConverter(); }
/// <summary> /// loads the given data in json format and stores it in the given classifier dictionary /// </summary> public void Load(JsonContent jsonContent,Diagram diagram) { var toDomainConverter = new DomainDtoConverter(); var diagramDto = LoadDto(jsonContent); toDomainConverter.ToDomain(diagram, diagramDto); }
public JsonContent Save(Diagram diagram) { var toDtoConverter = new DomainDtoConverter(); var diagramDto = toDtoConverter.ToDto(diagram); return SaveDto(diagramDto); }