Exemplo n.º 1
0
 public DeletionService(
     ClassifierDictionary classifiers,
     MessageSystem messageSystem)
 {
     _classifiers = classifiers;
     _messageSystem = messageSystem;
 }
        public void CreateNewClassTest()
        {
            _classifiers = new ClassifierDictionary();
            var newClass = _classifiers.CreateNewClass("Class");

            Assert.AreEqual("Class", newClass.Name);
        }
 public InterfaceSelectionItemsSource(
     ClassifierDictionary classifiers,
     IQuery<Classifier> availableClassifiers,
     MessageSystem messageSystem):base(classifiers,availableClassifiers.Get,messageSystem)
 {
     _classifiers = classifiers;
 }
Exemplo n.º 4
0
        public void ClassifierWithBaseClass_ConvertToDto_KeepBaseClass()
        {
            Car.BaseClass = Vehicle;
            _classifiers = new ClassifierDictionary(Car, Vehicle);
            var dtos = _converter.ToDto(new Diagram(_classifiers)).Classifiers;

            Assert.AreEqual(dtos[0].BaseClass,dtos[1]);
        }
 public ChangeInterfaceOfClassifierCommand(
     Implementation existingInterface, 
     ClassifierDictionary classifiers,
     MessageSystem messageSystem)
 {
     _existingInterface = existingInterface;
     _classifiers = classifiers;
     _messageSystem = messageSystem;
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public NewClassifierCommand(
            ClassifierDictionary classifiers,
            MessageSystem messageSystem)
        {
            Requires(classifiers != null);
            Requires(messageSystem != null);

            _classifiers = classifiers;
            _messageSystem = messageSystem;
        }
 protected override void Init()
 {
     _property = For<Property>();
     _classifiers = CreateDictionaryWithoutSystemTypes();
     _messageSystem = For<MessageSystem>();
     _oldType = new Classifier(Old);
     _newType = new Classifier(New);
     _classifiers.FindByName(Old).Returns(_oldType);
     _classifiers.FindByName(New).Returns(_newType);
 }
        public void ClassifiersWithMethods_WriteTo()
        {
            _result = "[Service|void DoSomething();]";
            _classifiers = new ClassifierDictionary(Service);
            Service.IsVisible = true;
            Service.Methods.Single().IsVisible = true;

            _classifiers.WriteTo(_diagramWriter);
            var umlText = _diagramWriter.ToString();

            Assert.AreEqual(_result, umlText);
        }
Exemplo n.º 10
0
        public void ClassifierWithMethod_ConvertToDto_KeepReferences()
        {
            // Arrange
            _classifiers = new ClassifierDictionary(Void, String, Service);
          
            // Act
            var dtos = _converter.ToDto(new Diagram(_classifiers)).Classifiers;

            // Assert
            Assert.AreEqual(dtos[0], dtos[2].Methods[0].ReturnType);
            Assert.AreEqual(dtos[1], dtos[2].Methods[0].Parameters[0].Type);
        }
 public void OnNameChangedTest()
 {
     // Arrange
     var classifier3 = new Classifier(3.ToString());
     var classifier2 = new Classifier(2.ToString());
     var classifiers = new ClassifierDictionary(classifier3, classifier2);
     var classifierSelectionSource = new ClassifierSelectionItemsSource(classifiers,_ => true,_messageSystem);
     // Act
     classifierSelectionSource.OnNameChanged(new NameChangedEvent(3.ToString(), 1.ToString()));
     // Assert: after renaming, item should be at first position
     Assert.IsTrue(classifierSelectionSource.First().Name == 1.ToString());
 }
Exemplo n.º 12
0
        public void Classifiers_ConvertToDto_KeepReferences()
        {
            // Arrange
            _classifiers = new ClassifierDictionary(Integer, String);
          
            // Act
            var dtos = _converter.ToDto(new Diagram(_classifiers)).Classifiers;

            // ensure that integer classifier is the same reference
            // for the dto and the type of the string's property
            Assert.AreEqual(dtos[0], dtos[1].Properties[0].Type);
            Assert.AreEqual(dtos[1], dtos[0].Properties[0].Type);
        }
        public void RenameClassifierTest()
        {
            var oldName = RandomString(1);
            var newName = RandomString(2);

            var classifier = new Classifier(oldName);
            _classifiers = new ClassifierDictionary(classifier);
            _classifiers.RenameClassifier(classifier, newName);

            Assert.AreEqual(newName, classifier.Name);
            Assert.IsTrue(_classifiers.IsClassNameFree(oldName));
            Assert.IsNotNull(_classifiers.FindByName(newName));
        }
 public BaseClassSelectionItemSource(
    ClassifierDictionary classifiers,
    string derivedClassName,
    MessageSystem messageSystem):
     base(
         classifiers, 
         () => classifiers.Where(x => 
             x.Name != derivedClassName && 
             !x.IsSystemType),
         messageSystem,true)
 {
     _classifiers = classifiers;
 }
Exemplo n.º 15
0
        public void CreateNewInterfaceImplementation()
        {
            var implementations = For<ImplementationList>();
            var classifiers = new ClassifierDictionary();
            var messageSystem = For<MessageSystem>();
            var implementation = For<Implementation>();
            implementations.CreateNew(classifiers).Returns(implementation);

            var newCommand = new NewCommand<Implementation>(implementations, classifiers, messageSystem);
            newCommand.CreateNew();

            messageSystem.Received().PublishCreated(implementations, implementation);
        }
Exemplo n.º 16
0
        public ViewModelContext(
            ClassifierDictionary availableClassifiers,
            CommandFactory commandFactory,
            MessageSystem messageSystem)
        {
            Requires(availableClassifiers != null);
            Requires(messageSystem != null);

            Classifiers = availableClassifiers;
            MessageSystem = messageSystem;
            ViewModelFactory = new ViewModelFactory(this);
            CommandFactory = commandFactory;
        }
        public void Classifiers_WriteTo()
        {
            _result = "[string],[int]";

            _classifiers = new ClassifierDictionary(String, Integer);
            String.IsVisible = true;
            Integer.IsVisible = true;

            _classifiers.WriteTo(_diagramWriter);
            var umlText = _diagramWriter.ToString();

            Assert.AreEqual(_result, umlText);
        }
        public void ClassifiersWithProperties_WriteTo()
        {
            _result = "[string|int Length;]";

            _classifiers = new ClassifierDictionary(String);
            String.IsVisible = true;
            String.Properties.Single().IsVisible = true;


            _classifiers.WriteTo(_diagramWriter);
            var umlText = _diagramWriter.ToString();

            Assert.AreEqual(_result, umlText);
        }
 public void FindAllImplementersTest()
 {
     // setup a class that implements an interface
     var @interface = new Classifier("interface") {IsInterface = true};
     var classifier = For<Classifier>("class",false);
     var subSet = For<ImplementationList.SubSet>();
     subSet.IsNotEmpty().Returns(true);
     classifier.FindImplementationsOfInterface(@interface).Returns(subSet);
     _classifiers = new ClassifierDictionary(classifier);
     
     // return all classes that have an implementation for the given interface
     var implementers = _classifiers.FindAllImplementers(@interface);
     
     // ensure that the implementer is in the result list
     Assert.Contains(classifier, implementers.ToList());
 }
        protected override void Init()
        {
            _validationService = For<IValidateNameService>();
            _messageSystem = For<MessageSystem>();

            _classifierDictionary = CreateDictionaryWithoutSystemTypes();
            _classifier = new Classifier("Integer");

            _renameCommand = new RenameClassifierCommand(
                _classifier, 
                _classifierDictionary,
                _validationService,
                _messageSystem);

            _newName = RandomString();
        }
Exemplo n.º 21
0
        public void SaveLoad_Test()
        {
            var fromClassifiers = new ClassifierDictionary(String);
            var toClassifiers = new ClassifierDictionary();
            var fromDiagram = new Diagram(fromClassifiers);
            var toDiagram = new Diagram(toClassifiers);
           
            var serializer = new JsonSerializer();

            // store the classifiers as json
            var json = serializer.Save(fromDiagram);
            // read them from json to another dictionary
            serializer.Load(json, toDiagram);

            // Ensure that both have the same classifiers
            Assert.IsTrue(toClassifiers.Count(x => x.Name == String.Name) == 1);
        }
 public ClassifierSingleCommandContext(
     Classifier classifier,
     ClassifierDictionary classifierDictionary,
     DeletionService deletionService,
     IRelationService relationService,
     IAskUserBeforeDeletionService askUserService,
     MessageSystem messageSystem)
 {
     Rename = new RenameClassifierCommand(
         classifier,
         classifierDictionary,
         new ClassifierValidationService(classifierDictionary),
         messageSystem);
     ChangeBaseClass = new ChangeBaseClassCommand(
         classifier,
         classifierDictionary,
         messageSystem);
     Delete = new DeleteClassifierCommand(classifier, deletionService,askUserService);
     Visibility = new ShowOrHideSingleObjectCommand(classifier, messageSystem);
     ChangeClassifierColor = new ChangeColorCommand(classifier, messageSystem);
     ChangeNoteColor = new ChangeNoteColorCommand(classifier.Note,messageSystem);
     ChangeNoteText = new ChangeNoteTextCommand(classifier.Note,messageSystem);
     ChangeIsInterface = new MakeClassifierToInterfaceCommand(classifier, relationService);
 }
Exemplo n.º 23
0
 /// <summary>
 /// constructor used for testing only 
 /// </summary>
 /// <param name="classifiers"></param>
 internal Diagram(ClassifierDictionary classifiers)
 {
     Classifiers = classifiers;
 }
Exemplo n.º 24
0
 protected override void Init()
 {
     _messageSystem = For<MessageSystem>();
     _classifiers = CreateDictionaryWithoutSystemTypes();
 }
 public ClassifierValidationService(ClassifierDictionary classifiers)
 {
     _classifiers = classifiers;
 }
Exemplo n.º 26
0
 protected override void Init()
 {
     _classifierDictionary = new ClassifierDictionary();
 }
Exemplo n.º 27
0
 protected override void Init()
 {
     _classifiers = CreateDictionaryWithoutSystemTypes();
     _classifiers.String.Returns(String);
 }
 protected override void Init()
 {
     _classifiers = CreateDictionaryWithoutSystemTypes();
     _validationService = new ClassifierValidationService(_classifiers);
 }
 public void ClassifierDictionary_NoSystemTypes()
 {
     _classifiers = new ClassifierDictionary(false);
     Assert.IsEmpty(_classifiers);
 }
 public void ClassifierDictionary_WithSystemTypes()
 {
     _classifiers = new ClassifierDictionary();
     Assert.IsNotEmpty(_classifiers);
 }