public void GetTargetFramework(string targetFramework, string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile, string expectedTargetFramework)
        {
            var properties = new Dictionary <string, string>();

            if (targetFramework != null)
            {
                properties.Add("TargetFramework", targetFramework);
            }
            if (targetFrameworkIdentifier != null)
            {
                properties.Add("TargetFrameworkIdentifier", targetFrameworkIdentifier);
            }
            if (targetFrameworkVersion != null)
            {
                properties.Add("TargetFrameworkVersion", targetFrameworkVersion);
            }
            if (targetFrameworkProfile != null)
            {
                properties.Add("TargetFrameworkProfile", targetFrameworkProfile);
            }

            var project = IProjectFactory.Create(properties);
            var actualTargetFramework = ProjectExtensions.GetTargetFramework(project);

            Assert.Equal(expectedTargetFramework, actualTargetFramework);
        }
Exemplo n.º 2
0
        public void PropertiesDiff_GetLines()
        {
            var defaultedProps = IProjectFactory.Create("A=B;C=D").Properties.ToImmutableArray();
            var removedProps   = IProjectFactory.Create("E=F;G=H").Properties.ToImmutableArray();
            var changedProps   = IProjectFactory.Create("I=J").Properties.Zip(IProjectFactory.Create("I=K").Properties, (a, b) => (a, b)).ToImmutableArray();
            var diff           = new PropertiesDiff(defaultedProps, removedProps, changedProps);

            var lines         = diff.GetDiffLines();
            var expectedLines = new[]
            {
                "Properties that are defaulted by the SDK:",
                "- A = B",
                "- C = D",
                "",
                "Properties that are not defaulted by the SDK:",
                "+ E = F",
                "+ G = H",
                "",
                "Properties whose value is different from the SDK's default:",
                "- I = J",
                "+ I = K",
                ""
            };

            Assert.Equal(expectedLines, lines);
        }
Exemplo n.º 3
0
        private Project CreateProject(Data.Entities.Project entity)
        {
            var project = _projectFactory.Create(entity.Id, entity.UserId);

            project.Name        = entity.Name;
            project.Description = entity.Description;
            return(project);
        }
Exemplo n.º 4
0
        public Guid Create([FromBody] ProjectModel model)
        {
            model.Id = Guid.NewGuid();
            var project = _factory.Create(model.Id, Const.UserId);

            project.CopyModelFields(model);
            _repository.Save(project);
            return(model.Id);
        }
        public void ItemsDiff(string projectItems, string sdkBaselineItems, string expectedDefaultedItems, string expectedNotDefaultedItems, string expectedIntroducedItems, string expectedChangedItems)
        {
            var project            = IProjectFactory.Create(GetItems(projectItems));
            var sdkBaselineProject = IProjectFactory.Create(GetItems(sdkBaselineItems));

            var differ = new Differ(project, sdkBaselineProject);

            var diffs = differ.GetItemsDiff();

            if (expectedDefaultedItems == null)
            {
                Assert.All(diffs, diff => Assert.Empty(diff.DefaultedItems));
            }
            else
            {
                var expectedDiffItems = GetItems(expectedDefaultedItems);
                var matchingItems     = diffs.Select(diff => (diff.DefaultedItems.Select(i => i.EvaluatedInclude), expectedDiffItems.SingleOrDefault(d => d.ItemType == diff.ItemType).Items));
                Assert.All(matchingItems, diff => Assert.Equal(diff.Item1, diff.Items));
            }

            if (expectedNotDefaultedItems == null)
            {
                Assert.All(diffs, diff => Assert.Empty(diff.NotDefaultedItems));
            }
            else
            {
                var expectedDiffItems = GetItems(expectedNotDefaultedItems);
                var matchingItems     = diffs.Select(diff => (diff.NotDefaultedItems.Select(i => i.EvaluatedInclude), expectedDiffItems.SingleOrDefault(d => d.ItemType == diff.ItemType).Items));
                Assert.All(matchingItems, diff => Assert.Equal(diff.Item1, diff.Items));
            }

            if (expectedIntroducedItems == null)
            {
                Assert.All(diffs, diff => Assert.Empty(diff.IntroducedItems));
            }
            else
            {
                var expectedDiffItems = GetItems(expectedIntroducedItems);
                var matchingItems     = diffs.Select(diff => (diff.IntroducedItems.Select(i => i.EvaluatedInclude), expectedDiffItems.SingleOrDefault(d => d.ItemType == diff.ItemType).Items));
                Assert.All(matchingItems, diff => Assert.Equal(diff.Item1, diff.Items));
            }

            if (expectedChangedItems == null)
            {
                Assert.All(diffs, diff => Assert.Empty(diff.ChangedItems));
            }
            else
            {
                var expectedDiffItems = GetItems(expectedChangedItems);
                var matchingItems     = diffs.Select(diff => (diff.ChangedItems.Select(i => i.EvaluatedInclude), expectedDiffItems.SingleOrDefault(d => d.ItemType == diff.ItemType).Items));
                Assert.All(matchingItems, diff => Assert.Equal(diff.Item1, diff.Items));
            }
        }
Exemplo n.º 6
0
    public IProject Create()
    {
        var project = createNewProject.Create() as Project; // TODO: don't cast, refactor to use IProject instead

        Debug.Assert(project?.Data != null);

        var snesData = project.Data.GetSnesApi();

        Debug.Assert(snesData != null);

        snesData.CacheVerificationInfoFor(project);

        return(project);
    }
Exemplo n.º 7
0
        public Project Add(Project item)
        {
            try
            {
                var project = _mapper.Map <ProjectDTO>(item);
                var result  = _factory.Create(project);
                return(result.Result);
            }
            catch (Exception e)
            {
                _logger.LogError($"There is a problem with save Project : {e}");
            }

            return(null);
        }
        public void ItemsDiff_GetLines_Partial()
        {
            var defaultedItems  = IProjectFactory.Create(GetItems("X:Y,Z")).Items.ToImmutableArray();
            var removedItems    = ImmutableArray <IProjectItem> .Empty;
            var introducedItems = ImmutableArray <IProjectItem> .Empty;
            var changedItems    = ImmutableArray <IProjectItem> .Empty;
            var diff            = new ItemsDiff("X", defaultedItems, removedItems, introducedItems, changedItems);

            var lines         = diff.GetDiffLines();
            var expectedLines = new[]
            {
                "X items:",
                "- Y",
                "- Z",
                "",
            };

            Assert.Equal(expectedLines, lines);
        }
Exemplo n.º 9
0
    public Project Read()
    {
        var project = baseProjectFactory.Create()
                      as Project; // TODO: after more refactoring, remove cast and use IProject directly

        Debug.Assert(project?.Data != null);

        project.AttachedRomFilename = importSettings.RomFilename;
        project.Session             = new ProjectSession(project, "")
        {
            UnsavedChanges = true
        };

        var snesApi = project.Data.GetSnesApi();

        Debug.Assert(snesApi != null);

#if DIZ_3_BRANCH
        // new way, though TODO we want to decouple the SNES stuff from here
        project.Data.PopulateFrom(importSettings.RomBytes, importSettings.RomMapMode, importSettings.RomSpeed);
#else
        // old way
        snesApi.RomMapMode = importSettings.RomMapMode;
        snesApi.RomSpeed   = importSettings.RomSpeed;
        project.Data.RomBytes.CreateRomBytesFromRom(importSettings.RomBytes);
#endif

        foreach (var(romOffset, label) in importSettings.InitialLabels)
        {
            var snesAddress = snesApi.ConvertPCtoSnes(romOffset);
            project.Data.Labels.AddLabel(snesAddress, label, true);
        }

        foreach (var(offset, flagType) in importSettings.InitialHeaderFlags)
        {
            snesApi.SetFlag(offset, flagType);
        }

        snesApi.CacheVerificationInfoFor(project);

        return(project);
    }
        public void GetTargetFramework_Throws(string targetFramework, string targetFrameworkIdentifier, string targetFrameworkVersion)
        {
            var properties = new Dictionary <string, string>();

            if (targetFramework != null)
            {
                properties.Add("TargetFramework", targetFramework);
            }
            if (targetFrameworkIdentifier != null)
            {
                properties.Add("TargetFrameworkIdentifier", targetFrameworkIdentifier);
            }
            if (targetFrameworkVersion != null)
            {
                properties.Add("TargetFrameworkVersion", targetFrameworkVersion);
            }

            var project = IProjectFactory.Create(properties);

            Assert.Throws <InvalidOperationException>(() => ProjectExtensions.GetTargetFramework(project));
        }
        public void ItemsDiff_GetLines()
        {
            var defaultedItems  = IProjectFactory.Create(GetItems("A:B,C")).Items.ToImmutableArray();
            var removedItems    = IProjectFactory.Create(GetItems("A:D,E")).Items.ToImmutableArray();
            var introducedItems = IProjectFactory.Create(GetItems("A:F,G")).Items.ToImmutableArray();
            var changedItems    = ImmutableArray <IProjectItem> .Empty;
            var diff            = new ItemsDiff("A", defaultedItems, removedItems, introducedItems, changedItems);

            var lines         = diff.GetDiffLines();
            var expectedLines = new[]
            {
                "A items:",
                "- B",
                "- C",
                "= D",
                "= E",
                "+ F",
                "+ G",
                "",
            };

            Assert.Equal(expectedLines, lines);
        }
Exemplo n.º 12
0
        public void PropertiesDiff(string projectProps, string propsInFile, string sdkBaselineProps, string expectedDefaultedProps, string expectedNotDefaultedProps, string expectedChangedProps)
        {
            var project            = IProjectFactory.Create(projectProps, propsInFile);
            var sdkBaselineProject = IProjectFactory.Create(sdkBaselineProps, propsInFile);

            var differ = new Differ(project, sdkBaselineProject);

            var diff = differ.GetPropertiesDiff();

            if (expectedDefaultedProps == null)
            {
                Assert.Empty(diff.DefaultedProperties);
            }
            else
            {
                Assert.Equal(diff.DefaultedProperties.Select(p => p.Name), expectedDefaultedProps.Split(';'));
            }

            if (expectedNotDefaultedProps == null)
            {
                Assert.Empty(diff.NotDefaultedProperties);
            }
            else
            {
                Assert.Equal(diff.NotDefaultedProperties.Select(p => p.Name), expectedNotDefaultedProps.Split(';'));
            }

            if (expectedChangedProps == null)
            {
                Assert.Empty(diff.ChangedProperties);
            }
            else
            {
                Assert.Equal(diff.ChangedProperties.Select(p => p.oldProp.Name), expectedChangedProps.Split(';'));
            }
        }
Exemplo n.º 13
0
 private IEnumerable <IProject> Wrap(IEnumerable <IProjectInSolution> source)
 {
     return(source
            .Where(p => p.AbsolutePath.EndsWith(CsProjExtension))
            .Select(p => _projectFactory.Create(p)));
 }