Ejemplo n.º 1
0
            public void GeneratesIdFromHandle()
            {
                HandleHelper.GenerateId("handle").Returns("derived-id");
                var spec = new ContainerSpec
                {
                    Handle = "handle",
                };

                var container = Service.CreateContainer(spec);

                Assert.Equal("derived-id", container.Id);
            }
Ejemplo n.º 2
0
        public ContainerServiceTests()
        {
            ContainerBasePath  = @"C:\Containers";
            ContainerUserGroup = "ContainerUsers";

            ContainerPropertiesService = Substitute.For <IContainerPropertyService>();

            FileSystem = Substitute.For <IFileSystemManager>();

            Id = "DEADBEEF";

            HandleHelper = Substitute.For <ContainerHandleHelper>();
            HandleHelper.GenerateId(null).ReturnsForAnyArgs(Id);

            ProcessRunner  = Substitute.For <IProcessRunner>();
            TcpPortManager = Substitute.For <ILocalTcpPortManager>();
            UserManager    = Substitute.For <IUserManager>();

            ContainerHostClient = Substitute.For <IContainerHostClient>();

            ContainerHostService = Substitute.For <IContainerHostService>();
            ContainerHostService.StartContainerHost(null, null, null, null)
            .ReturnsForAnyArgs(ContainerHostClient);

            UserManager.CreateUser(null).ReturnsForAnyArgs(new NetworkCredential("username", "password"));
            sid = "S-1234";
            UserManager.GetSID(null).ReturnsForAnyArgs(sid);

            diskQuotaManager   = Substitute.For <IDiskQuotaManager>();
            containerDiskQuota = Substitute.For <IContainerDiskQuota>();
            diskQuotaManager.CreateDiskQuotaControl(null, "").ReturnsForAnyArgs(containerDiskQuota);

            var directoryFactory = Substitute.For <IContainerDirectoryFactory>();

            containerDirectory = Substitute.For <IContainerDirectory>();
            directoryFactory.Create(FileSystem, ContainerBasePath, Id).Returns(containerDirectory);

            var containerFactory = new TestContainerFactory();

            Service = new ContainerService(
                HandleHelper,
                UserManager,
                FileSystem,
                ContainerPropertiesService,
                TcpPortManager,
                ProcessRunner,
                ContainerHostService,
                diskQuotaManager,
                directoryFactory,
                containerFactory,
                ContainerBasePath
                );
        }