public async Task GetApplicationsByNameTest()
        {
            var appSpec = new ApplicationSpecification();

            appSpec.Name = "MyApp1";
            var repo         = new EfRepository <Application>(this.DbContext);
            var applications = await repo.ListAsync(appSpec);

            Assert.IsTrue(applications.Any());
        }
        public ConfigurationQuery(IDataLoaderContextAccessor accessor, IAsyncRepository <Location> locationRepository,
                                  IAsyncRepository <TrustLevel> trustLevelRepository,
                                  IAsyncRepository <Inventory.Domain.Models.Environment> environmentRepository,
                                  IAsyncRepository <Inventory.Domain.Models.Application> applicationRepository)
        {
            Field <ListGraphType <LocationType>, IReadOnlyList <Location> >()
            .Name("Locations")
            .ResolveAsync(ctx =>
            {
                return(locationRepository.ListAllAsync());
            });

            Field <ListGraphType <TrustLevelType>, IReadOnlyList <TrustLevel> >()
            .Name("TrustLevels")
            .ResolveAsync(ctx =>
            {
                return(trustLevelRepository.ListAllAsync());
            });

            Field <ListGraphType <EnvironmentType>, IReadOnlyList <Inventory.Domain.Models.Environment> >()
            .Name("Environments")
            .Argument <StringGraphType>("name")
            .ResolveAsync(ctx =>
            {
                var envName = ctx.GetArgument <string>("name");
                if (string.IsNullOrWhiteSpace(envName))
                {
                    var envSpec = new EnvironmentSpecification();
                    return(environmentRepository.ListAsync(envSpec));
                }
                else
                {
                    var envSpec = new EnvironmentSpecification(envName);
                    return(environmentRepository.ListAsync(envSpec));
                }
            });

            Field <ListGraphType <ApplicationType>, IReadOnlyList <Inventory.Domain.Models.Application> >()
            .Name("Applications")
            .Argument <StringGraphType>("name")
            .Argument <StringGraphType>("code")
            .ResolveAsync(ctx =>
            {
                var appSpec  = new ApplicationSpecification();
                appSpec.Name = ctx.GetArgument <string>("name");
                appSpec.Code = ctx.GetArgument <string>("code");
                return(applicationRepository.ListAsync(appSpec));
                //return applicationRepository.ListAllAsync();
            });
        }
Beispiel #3
0
        public async Task <ILookup <int, ServerDto> > GetServersByApplicationAsync(IEnumerable <int> applicationIds, CancellationToken token)
        {
            var appSpec = new ApplicationSpecification()
            {
                ApplicationIds = applicationIds.ToArray()
            };

            var applicationsServers = await _applicationRepository.ListAsync(appSpec);

            return(applicationsServers.SelectMany(a => a.Servers, (a, srv) => new { a.ApplicationId, srv }).ToLookup(a => a.ApplicationId, a =>
            {
                var dtoServer = GetOrFillServerData(a.srv);
                dtoServer.Wait();
                return dtoServer.Result;
            }));
        }
        public void IsNewerOrEqualVersionOfWithEqualVersion()
        {
            var config1 = new ApplicationSpecification("app", new Version(1, 0));
            var config2 = new ApplicationSpecification("app", new Version(1, 0));

            Assert.IsTrue(config1.IsNewerOrEqualVersionOf(config2));
        }
        public void Create()
        {
            var name = "a";
            var version = new Version(10, 9, 8, 7);
            var spec = new ApplicationSpecification(name, version);

            Assert.AreSame(name, spec.ApplicationName);
            Assert.AreSame(version, spec.ApplicationVersion);
        }
        public void IsOlderVersionOfWithUnequalAppName()
        {
            var config1 = new ApplicationSpecification("app1", new Version(1, 0));
            var config2 = new ApplicationSpecification("app2", new Version(1, 0));

            Assert.IsFalse(config1.IsOlderVersionOf(config2));
        }
 public void IsOlderVersionOfWithSelf()
 {
     var config1 = new ApplicationSpecification("app1", new Version(1, 0));
     Assert.IsFalse(config1.IsOlderVersionOf(config1));
 }
        public void IsOlderVersionOfWithOlderVersion()
        {
            var config1 = new ApplicationSpecification("app", new Version(1, 0));
            var config2 = new ApplicationSpecification("app", new Version(2, 0));

            Assert.IsTrue(config1.IsOlderVersionOf(config2));
        }
 public void IsOlderVersionOfWithNullOther()
 {
     var config1 = new ApplicationSpecification("app1", new Version(1, 0));
     Assert.IsFalse(config1.IsOlderVersionOf(null));
 }
        public void IsOlderOrEqualVersionOfWithNewerVersion()
        {
            var config1 = new ApplicationSpecification("app", new Version(1, 1));
            var config2 = new ApplicationSpecification("app", new Version(1, 0));

            Assert.IsFalse(config1.IsOlderOrEqualVersionOf(config2));
        }