Ejemplo n.º 1
0
        public void DthStartup_GetProjectInformation(DnxSdk sdk)
        {
            using (var server = sdk.Dth.CreateServer())
            using (var client = new DthTestClient(server))
            {
                var solution = TestProjectsRepository.EnsureRestoredSolution("DthTestProjects");
                var project = solution.GetProject("EmptyConsoleApp");

                sdk.Dnu.Restore(project).EnsureSuccess();

                client.Initialize(project.ProjectDirectory);

                var projectInformation = client.DrainTillFirst("ProjectInformation")
                                               .EnsureSource(server, client)
                                               .RetrievePayloadAs<JObject>()
                                               .AssertProperty("Name", project.Name);

                projectInformation.RetrievePropertyAs<JArray>("Configurations")
                                  .AssertJArrayCount(2)
                                  .AssertJArrayContains("Debug")
                                  .AssertJArrayContains("Release");

                var frameworkShortNames = projectInformation.RetrievePropertyAs<JArray>("Frameworks")
                                                            .AssertJArrayCount(2)
                                                            .Select(f => f["ShortName"].Value<string>());

                Assert.Contains("dnxcore50", frameworkShortNames);
                Assert.Contains("dnx451", frameworkShortNames);

                TestUtils.CleanUpTestDir<DthStartupTests>(sdk);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Throws if the message is not generated in communication between given server and client
        /// </summary>
        public static DthMessage EnsureSource(this DthMessage message, DthTestServer server, DthTestClient client)
        {
            if (message.HostId != server.HostId)
            {
                throw new Exception($"{nameof(message.HostId)} doesn't match the one of server. Expected {server.HostId} but actually {message.HostId}.");
            }

            return(message);
        }