Пример #1
0
        public async Task GetListedValuesAsync_ReturnsSupportedTargetFrameworksItems()
        {
            string project =
                @"<Project>
    <ItemGroup>
        <SupportedTargetFramework Include="".NETCoreApp,Version=v1.0"" DisplayName="".NET Core 1.0"" />
        <SupportedTargetFramework Include="".NETCoreApp,Version=v1.1"" DisplayName="".NET Core 1.1"" />
        <SupportedTargetFramework Include="".NETCoreApp,Version=v2.0"" DisplayName="".NET Core 2.0"" />
    </ItemGroup>
</Project>";

            var projectAccessor = IProjectAccessorFactory.ImplementOpenProjectForReadAsync <ICollection <IEnumValue> >(project);

            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            var values = await generator.GetListedValuesAsync();

            AssertEx.CollectionLength(values, 3);
            Assert.Equal(new List <string> {
                ".NETCoreApp,Version=v1.0", ".NETCoreApp,Version=v1.1", ".NETCoreApp,Version=v2.0"
            }, values.Select(v => v.Name));
            Assert.Equal(new List <string> {
                ".NET Core 1.0", ".NET Core 1.1", ".NET Core 2.0"
            }, values.Select(v => v.DisplayName));
        }
        public async Task Constructor()
        {
            var projectXmlAccessor = IProjectXmlAccessorFactory.Create();
            var configuredProject  = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectXmlAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.NotNull(generator);
        }
Пример #3
0
        public async Task TryCreateEnumValueAsync_ReturnsNull()
        {
            var projectAccessor   = IProjectAccessorFactory.Create();
            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.Null(await generator.TryCreateEnumValueAsync("foo"));
        }
Пример #4
0
        public async Task TryCreateEnumValueAsync_ThrowsNotImplemented()
        {
            var projectAccessor   = IProjectAccessorFactory.Create();
            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.Throws <NotImplementedException>(() =>
            {
                generator.TryCreateEnumValueAsync("foo");
            });
        }