示例#1
0
        public async Task Single_Space_Can_Be_Fetched()
        {
            await _repository.Add(new Space(new SpaceName("single")));

            Space space = (Space)await _repository.Get(new SpaceName("single"));

            Assert.NotNull(space);
            Assert.Equal("single", space.Name.ToString());
            Assert.Equal(
                new DirectoryInfo(Path.Combine(_rootPath, "single")).FullName,
                space.BaseDirectory?.FullName);
        }
示例#2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Please specify your name");
                return;
            }
            // Instantiate a new Space repository.
            SpaceRepository repository = new SpaceRepository();

            // Add a gate, such that we can connect to it.
            repository.AddGate("tcp://127.0.0.1:123?CONN");

            // Add a new Fifo based space.
            repository.AddSpace("dtu", new SequentialSpace());

            // Insert a tuple with a message.
            repository.Put("dtu", "Hello student!");

            // Instantiate a remotespace (a networked space) thereby connecting to the spacerepository.
            ISpace remotespace = new RemoteSpace("tcp://127.0.0.1:123/dtu?CONN");

            // Instantiate a new agent, assign the tuple space and start it.
            AgentBase student = new Student(args[0], remotespace);

            student.Start();

            // Wait and retrieve the message from the agent.
            ITuple tuple = repository.Get("dtu", typeof(string), typeof(string));

            // Print the contents to the console.
            Console.WriteLine(string.Format("{0}, you are attending course {1}", tuple[0], tuple[1]));
            Console.Read();
        }
示例#3
0
        public async Task Space_Is_Retrievable_After_Creation()
        {
            var createSpacePresenter = new CreateSpacePresenter();
            var useCase = new Application.UseCases.CreateSpace(createSpacePresenter, _spaceService);

            var input = new CreateSpaceInput(new SpaceName("Demo"));
            await useCase.Execute(input);

            Assert.Single(createSpacePresenter.CreatedSpaces);

            ISpace createdSpace = await _spaceRepository.Get(new SpaceName("Demo"));

            Assert.Equal("Demo", createdSpace.Name.ToString());
        }
 /// <summary>
 /// Returns the root directory of current logged user
 /// </summary>
 /// <param name="userId">current logged user Id</param>
 /// <returns>Root directory folder - Field</returns>
 public Field GetRootField(Guid userId)
 {
     return(SpaceRepository.Get(n => n.Owner.Id == userId)
            .FirstOrDefault()
            .Directory);
 }