public async Task VersionWildcard_GetContent_LastContentGot() { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var atomId = new AtomId("PlainText", "Hello"); string version = "1.0.1"; var dbAtom = new Atom { Kind = atomId.Kind, Name = atomId.Name, Version = version }; dbAtom.Content = new AtomContent { Atom = dbAtom, Content = content }; context.Atoms.Add(dbAtom); context.SaveChanges(); // When using (var storage = new AtomStorage(context)) { var str = Encoding.UTF8.GetString(await storage.GetContentAsync(atomId)); // Then Assert.Equal(contentString, str); } }
public async Task AtomCreation_CreateAtomNoDeps_AtomWithNoDepsCreated() { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var atomId = new AtomId("PlainText", "Hello", "1.0.1"); // When using (var storage = new AtomStorage(context)) { await storage.AddAsync(atomId, Enumerable.Empty <AtomId>(), content); } // Then using (context = new InMemoryResolverContext()) { var dbAtom = context.Atoms.Include(a => a.Content) .Include(a => a.Dependencies) .ThenInclude(dep => dep.Dependency) .Single(a => a.Kind == atomId.Kind && a.Name == atomId.Name && a.Version == atomId.Version); Assert.Empty(dbAtom.Dependencies); var actualContentString = Encoding.UTF8.GetString(dbAtom.Content.Content); Assert.Equal(contentString, actualContentString); } }
public async Task VersionWildcard_CreateAtomWithoutPredcessors_CreatedAtomWithDefaultVersion() { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var atomId = new AtomId("PlainText", "Hello"); // When using (var storage = new AtomStorage(context)) { await storage.AddAsync(atomId, Enumerable.Empty <AtomId>(), content); } // Then using (context = new InMemoryResolverContext()) { var dbAtom = context.Atoms.Single(a => a.Kind == atomId.Kind && a.Name == atomId.Name); Assert.Equal(AtomId.DefaultVersion, dbAtom.Version); } }
public async Task AtomCreation_CreateAtomWithDeps_AtomWithDepsCreated() { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var dependency = new AtomId("PlainText", "Hello", "1.0.1"); var dependent = new AtomId("Sentence", "World", "1.0.0"); var dbAtomDep = new Atom { Kind = dependency.Kind, Name = dependency.Name, Version = dependency.Version }; dbAtomDep.Content = new AtomContent { Atom = dbAtomDep, Content = content }; context.Atoms.Add(dbAtomDep); context.SaveChanges(); // When using (var storage = new AtomStorage(context)) { await storage.AddAsync(dependent, Enumerable.Empty <AtomId>().Append(dependency), content); } // Then using (context = new InMemoryResolverContext()) { var dbAtom = context.Atoms.Include(a => a.Content) .Include(a => a.Dependencies) .ThenInclude(dep => dep.Dependency) .Single(a => a.Kind == dependent.Kind && a.Name == dependent.Name && a.Version == dependent.Version); Assert.Single(dbAtom.Dependencies); var dependencyAtom = dbAtom.Dependencies.Single().Dependency; Assert.Equal(dbAtomDep.Kind, dependencyAtom.Kind); Assert.Equal(dbAtomDep.Name, dependencyAtom.Name); Assert.Equal(dbAtomDep.Version, dependencyAtom.Version); } }
public async Task DependencyResolution_NotDependentAtomPassed_AtomOnlyReturned() { var storage = new AtomStorage(InitContext()); var atomId = await storage.AddAsync(new AtomId("text", "hello"), Enumerable.Empty <AtomId>(), new byte[0]); var resolver = new Resolver.Endpoint.Resolver(storage); var resolved = await resolver.ResolveAsync(new [] { atomId }); Assert.Single(resolved); var resolvedId = resolved.Single(); Assert.Equal(atomId, resolvedId); }
public async Task DependecyResolutionOrdering_MultipleAtomsDependent_CorrectOrderReturned() { var storage = new AtomStorage(InitContext()); var si = await storage.AddAsync(new AtomId("fsdecl", "SI"), Enumerable.Empty <AtomId>(), new byte[0]); var eeg = await storage.AddAsync(new AtomId("fsdecl", "Eeg"), Enumerable.Empty <AtomId>().Append(si), new byte[0]); var resolver = new Resolver.Endpoint.Resolver(storage); var resolved = await resolver.ResolveAsync(new [] { new AtomId("fsdecl", "Eeg"), new AtomId("fsdecl", "SI") }); Assert.Equal(new [] { si, eeg }, resolved); }
public async Task DependecyResolutionOrdering_SingleAtomDuplicateDeps_CorrectOrderReturned() { var storage = new AtomStorage(InitContext()); var si = await storage.AddAsync(new AtomId("fsdecl", "SI"), Enumerable.Empty <AtomId>(), new byte[0]); var eeg = await storage.AddAsync(new AtomId("fsdecl", "Eeg"), Enumerable.Empty <AtomId>().Append(si), new byte[0]); var workflow = await storage.AddAsync(new AtomId("filomena", "IcaFiltering"), Enumerable.Empty <AtomId>().Append(eeg).Append(si), new byte[0]); var resolver = new Resolver.Endpoint.Resolver(storage); var resolved = await resolver.ResolveAsync(new [] { workflow }); Assert.Equal(new [] { si, eeg, workflow }, resolved); }
public async Task VersionWildcard_CreateAtomWithPredcessor_CreatedAtomWithMinorIncremented( string predcessorVersion, string expectedVersion) { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var atomId = new AtomId("PlainText", "Hello"); var dbAtom = new Atom { Kind = atomId.Kind, Name = atomId.Name, Version = predcessorVersion }; context.Atoms.Add(dbAtom); context.SaveChanges(); // When using (var storage = new AtomStorage(context)) { await storage.AddAsync(atomId, Enumerable.Empty <AtomId>(), content); } // Then using (context = new InMemoryResolverContext()) { var addedAtom = context.Atoms.Single(a => a.Kind == atomId.Kind && a.Name == atomId.Name && a.Version != predcessorVersion); Assert.Equal(expectedVersion, addedAtom.Version); } }
public AtomsController(AtomStorage storage, Resolver resolver) { _storage = storage; _resolver = resolver; }
public Resolver(AtomStorage storage) { _storage = storage; }
public LispParser() { AtomStorage = new AtomStorage(this); RuntimeAtomStack = new RuntimeAtomStack(this); }
public async Task AtomAсquisition_GetDependencies_DependenciesGot() { // Given var context = InitContext(); var contentString = "Hello, world!"; var content = Encoding.UTF8.GetBytes(contentString); var dependency = new AtomId("PlainText", "Hello", "1.0.1"); var dependent = new AtomId("Sentence", "World", "1.0.0"); var dbAtomDep = new Atom { Kind = dependency.Kind, Name = dependency.Name, Version = dependency.Version }; dbAtomDep.Content = new AtomContent { Atom = dbAtomDep, Content = content }; var dbAtom = new Atom { Kind = dependent.Kind, Name = dependent.Name, Version = dependent.Version }; dbAtom.Content = new AtomContent { Atom = dbAtom, Content = content }; dbAtom.Dependencies = new List <AtomDependency> { new AtomDependency { Dependent = dbAtom, Dependency = dbAtomDep } }; context.Atoms.Add(dbAtomDep); context.Atoms.Add(dbAtom); context.SaveChanges(); // When using (var storage = new AtomStorage(context)) { var deps = await storage.GetDependenciesAsync(dependent); Assert.Single(deps); var dep = deps.Single(); // Then Assert.Equal(dependency.Kind, dep.Kind); Assert.Equal(dependency.Name, dep.Name); Assert.Equal(dependency.Version, dep.Version); } }