Exemple #1
0
        public DataItem CreateDataItem(Interaction parentInteraction)
        {
            int index = 0;

            if (parentInteraction.DataItems.Count > 0)
            {
                var lastDataItem = parentInteraction.DataItems.First(d => d.IsLast);

                lastDataItem.IsLast = false;

                itemSerializer.Save(lastDataItem, lastDataItem.Id.ToString());

                index = lastDataItem.Index + 1;
            }

            var dataItem = new DataItem() { Index = index, IsLast = true, ParentId = parentInteraction.Id };

            parentInteraction.DataItemIds.Add(dataItem.Id);

            parentInteraction.DataItems.Add(dataItem);

            parentInteraction.DataItems = parentInteraction.DataItems.OrderBy(d => d.Index).ToList();

            SaveInteraction(parentInteraction);

            return dataItem;
        }
        public void Given_Repository(bool cleanFolders)
        {
            if(cleanFolders)
                DeleteFiles();

            serializer = new ItemJsonSerializer(dataPath);

            repo = new ItemRepository(serializer);

            repo.DataPath = dataPath;

            projectItem = repo.Create<Project>() as Project;
            storyItem = repo.Create<Story>() as Story;
            scenarioItem = repo.Create<Scenario>() as Scenario;
            interactionItem = new Interaction();
            dataItem = new DataItem();
        }
        public void CreateInteraction()
        {
            var index = GetLastIndex();

            var interaction = new Interaction() { ParentId=Scenario.Id, Index=index };

            var dataItem = new DataItem() { ParentId = interaction.Id };

            interaction.DataItems.Add(dataItem);

            Interactions.Add(interaction);

            CreateViewModels();

            Update();
        }
        public DataItemViewModel(DataItem dataItem)
        {
            DataItem = dataItem;

            repo = App.kernel.Get<IRepository>();
        }
Exemple #5
0
 public void SaveDataItem(DataItem dataItem)
 {
     itemSerializer.Save(dataItem, dataItem.Id.ToString());
 }
Exemple #6
0
        public Interaction DeleteDataItem(Interaction interaction, DataItem dataItem)
        {
            interaction.DataItemIds.Remove(dataItem.Id);

            interaction.DataItems.Remove(dataItem);

            interaction.DataItems = ReIndexDataItems(interaction.DataItems);

            DeleteFile(dataItem.Id, dataItem.Type);

            return interaction;
        }
        public void Setup()
        {
            scenario = new Scenario()
            {
                Name = "foo",
                Description = "bar",
                TestDataRows = new List<TestData>(),
                Interactions = new List<Interaction>()
            };

            var interaction1 = new Interaction()
            {
                Name = "Step 1",
                DataItems = new List<DataItem>()
            };

            var interaction2 = new Interaction()
            {
                Name = "Step 2",
                DataItems = new List<DataItem>()
            };

            var dataItem = new DataItem()
            {
                Name = "param1"
            };

            var dataItem2 = new DataItem()
            {
                Name = "param2"
            };

            interaction1.DataItems.Add(dataItem);
            interaction1.DataItems.Add(dataItem2);

            interaction2.DataItems.Add(dataItem);
            interaction2.DataItems.Add(dataItem2);

            var testData1 = new TestData();
            testData1.Add("param1", "foo");
            testData1.Add("param2", "bar");

            var testData2 = new TestData();
            testData2.Add("param1", "foo");
            testData2.Add("param2", "bar");

            scenario.Interactions.Add(interaction1);
            scenario.Interactions.Add(interaction2);

            scenario.TestDataRows.Add(testData1);
            scenario.TestDataRows.Add(testData2);

            scenarios = new List<Item>();
            scenarios.Add(scenario);

            built = builder.Build(scenarios);
        }
Exemple #8
0
        public void CreateScenario()
        {
            var scenario = new Scenario() { ParentId = Story.Id };

            var interaction = new Interaction() { ParentId = scenario.Id };

            var dataItem = new DataItem() { ParentId = interaction.Id };

            interaction.DataItems.Add(dataItem);

            scenario.Interactions.Add(interaction);

            scenario.Name = "Scenario Name";

            Scenarios.Add(scenario);

            Story.ChildrenIds.Add(scenario.Id);

            var scenarioViewModel = new ScenarioViewModel(scenario, this) { IsSelected = true, IsExpanded = true };

            base.Children.Add(scenarioViewModel);

            Update();
        }
        public void DeleteDataItem(DataItem dataItem)
        {
            if (Interaction.DataItems.Count > 1)
            {
                DataItemViewModels.Remove(DataItemViewModels.FirstOrDefault(d => d.DataItem.Equals(dataItem)));

                DataItems.Remove(dataItem);

                OnPropertyChanged("DataItems");
            }
        }
        public void AddNewDataItem()
        {
            var index = GetLastIndex();

            var newDataItem = new DataItem() { ParentId = Interaction.Id, Index=index };

            Interaction.DataItems.Add(newDataItem);

            Interaction.ChildrenIds.Add(newDataItem.Id);

            DataItemViewModels.Add(new DataItemViewModel(newDataItem));

            OnPropertyChanged("DataItems");
        }