public async Task Does_not_add_a_PlaceholderComponent_with_a_non_existing_Id_and_sets_Error_to_NotFound()
        {
            var addComponentCommand = new AddComponentNodeCommand(9999, 0, 0);
            await addComponentCommand.Process(virtualStudio);

            Assert.IsNotNull(addComponentCommand.Error);
            Assert.IsTrue(addComponentCommand.Error.Type == ErrorType.NotFound);
            Assert.IsTrue(virtualStudio.Components.Count == 0);
        }
        public async Task Adds_a_cloned_PlaceholderComponent_from_ComponentRepository(float x, float y)
        {
            var placeholder = virtualStudio.ComponentRepository.Placeholders.First();

            var addComponentCommand = new AddComponentNodeCommand(placeholder.Id, x, y);
            await addComponentCommand.Process(virtualStudio);

            Assert.IsTrue(virtualStudio.Components.Count == 1);
            var addedPlaceholder = virtualStudio.ComponentNodes.First();

            Assert.AreNotEqual(placeholder.Id, addedPlaceholder.Id);
            Assert.AreEqual(x, addedPlaceholder.Position.X);
            Assert.AreEqual(y, addedPlaceholder.Position.Y);
        }
        public async Task Does_not_add_a_ClientComponent_that_already_exists_in_Components_and_sets_Error_to_InvalidOperation()
        {
            var clientComponentMock   = new Mock <IStudioComponent>();
            int clientComponentMockId = 2;

            clientComponentMock.SetupGet(c => c.Id).Returns(clientComponentMockId);
            virtualStudio.ComponentRepository.AddClient(clientComponentMock.Object);
            await new AddComponentNodeCommand(clientComponentMockId, 0, 0).Process(virtualStudio);

            var addComponentCommand = new AddComponentNodeCommand(clientComponentMockId, 0, 0);
            await addComponentCommand.Process(virtualStudio);

            Assert.IsTrue(virtualStudio.Components.Count == 1);
            Assert.IsTrue(addComponentCommand.Error.Type == ErrorType.InvalidOperation);
        }
        public async Task Adds_a_ClientComponent_from_ComponentRepository(float x, float y)
        {
            var clientComponentMock   = new Mock <IStudioComponent>();
            int clientComponentMockId = 2;

            clientComponentMock.SetupGet(c => c.Id).Returns(clientComponentMockId);
            virtualStudio.ComponentRepository.AddClient(clientComponentMock.Object);

            var addComponentCommand = new AddComponentNodeCommand(clientComponentMockId, x, y);
            await addComponentCommand.Process(virtualStudio);

            Assert.IsTrue(virtualStudio.Components.Count == 1);
            var addedComponentNode = virtualStudio.ComponentNodes.First();

            Assert.AreEqual(clientComponentMockId, addedComponentNode.Id);
            Assert.AreEqual(x, addedComponentNode.Position.X);
            Assert.AreEqual(y, addedComponentNode.Position.Y);
        }