Beispiel #1
0
        public Test_Hive(HiveFixture fixture)
        {
            if (!fixture.LoginAndInitialize(action:
                                            () =>
            {
                // This adds a [HostsFixture] to the [HiveFixture] (which inherits
                // from [TestFixtureSet]).  We'll name the HostFixture so we can use
                // it to setup local DNS entries for the tests.

                fixture.AddFixture("hosts", hosts = new HostsFixture());
            }))
            {
                // This call ensures that the hive is reset to a
                // pristine state before each test is invoked.

                fixture.Reset();

                // Retrieve the hosts fixture and reset it.

                hosts = (HostsFixture)fixture["hosts"];
                hosts.Reset();
            }

            this.hiveFixture = fixture;
            this.hive        = fixture.Hive;
        }
Beispiel #2
0
        public Test_ComposedFixture(ComposedFixture composedFixture)
        {
            this.composedFixture = composedFixture;

            var fixtureStatus = composedFixture.Start(
                () =>
            {
                // NOTE: Adding this one first because it clears the local Docker
                //       state when it starts and we want the containers started
                //       by the other fixtures to be unmolested.

                composedFixture.AddFixture("docker", new DockerFixture());

                composedFixture.AddFixture("aspNet", new AspNetFixture(),
                                           aspNetFixture =>
                {
                    aspNetFixture.StartAsComposed <Startup>();
                });

                composedFixture.AddFixture("container", new ContainerFixture(),
                                           containerFixture =>
                {
                    containerFixture.StartAsComposed("my-container", $"{NeonHelper.NeonLibraryBranchRegistry}/test:latest");
                });

                composedFixture.AddFixture("hosts", new HostsFixture());

                composedFixture.AddFixture("nats", new NatsFixture(),
                                           natsFixture =>
                {
                    natsFixture.StartAsComposed();
                });
            });

            this.aspNetFixture    = (AspNetFixture)composedFixture["aspNet"];
            this.dockerFixture    = (DockerFixture)composedFixture["docker"];
            this.containerFixture = (ContainerFixture)composedFixture["container"];
            this.hostsFixture     = (HostsFixture)composedFixture["hosts"];
            this.natsFixture      = (NatsFixture)composedFixture["nats"];

            if (fixtureStatus == TestFixtureStatus.Started)
            {
                hostsFixture.AddHostAddress("foo.bar", "127.1.2.3");
            }
        }
Beispiel #3
0
        public Test_Docker(DockerFixture fixture)
        {
            this.fixture = fixture;

            var reset = fixture.Initialize(
                () =>
            {
                // We're going to add a [HostsFixture] so tests can modify
                // the local [hosts] file to customize DNS lookups.  Note
                // that subfixtures are identified by name and can be
                // retrieved later using a fixture indexer.

                fixture.AddFixture("hosts", new HostsFixture());

                // Add a Couchbase instance to the test.

                fixture.AddFixture("couchbase", new CouchbaseFixture(), subFixture => subFixture.StartInAction());
            });

            // Fetch the hosts fixture so it'll be easy to access from
            // the tests.

            hosts     = (HostsFixture)fixture["hosts"];
            couchbase = (CouchbaseFixture)fixture["couchbase"];
            bucket    = couchbase.Bucket;

            if (!reset)
            {
                // Reset the fixture state if the [Initialize()]
                // method hasn't already done so.

                hosts.Reset();
                fixture.Reset();
                couchbase.Clear();
            }
        }