예제 #1
0
        public async Task TemplatesClient_List_With_Filter()
        {
            var connection = new Mock <IConnection>();

            connection.Setup(c => c.Get <IList <Template> >(ApiUrls.TemplatesList(), It.IsAny <IDictionary <string, string> >()))
            .ReturnsAsync(() =>
            {
                var json = System.IO.File.ReadAllText("./Fixtures/Templates_ListTemplates.json");
                return(JsonConvert.DeserializeObject <IList <Template> >(json));
            });

            var templateClient = new TemplatesClient(connection.Object);
            var result         = await templateClient.List(new TemplateFilter()
            {
                Id        = "1234",
                Label     = "Windows 10",
                OS        = "Windows 10 (Server 2019) - Licensed",
                Region    = "",
                Name      = "paperspace/tk9izniv",
                DTCreated = new System.DateTime(),
                UserId    = "12345",
                TeamId    = "12354"
            });

            Assert.AreEqual(14, result.Count);
        }
예제 #2
0
        public async Task TemplatesClient_List_HappyPath()
        {
            var connection = new Mock <IConnection>();

            connection.Setup(c => c.Get <IList <Template> >(ApiUrls.TemplatesList(), null))
            .ReturnsAsync(() =>
            {
                var json = System.IO.File.ReadAllText("./Fixtures/Templates_ListTemplates.json");
                return(JsonConvert.DeserializeObject <IList <Template> >(json));
            });

            var templateClient = new TemplatesClient(connection.Object);
            var result         = await templateClient.List();

            Assert.AreEqual(14, result.Count);
        }
        public async Task MachinesClient_Create_HappyPath()
        {
            var connection = new Mock <IConnection>();

            connection.Setup(c => c.Post <Machine>(ApiUrls.MachinesCreate(), null, It.IsAny <CreateMachineRequest>(), null, null))
            .ReturnsAsync(() =>
            {
                var json = System.IO.File.ReadAllText("./Fixtures/Machines_CreateMachine.json");
                return(JsonConvert.DeserializeObject <Machine>(json));
            });

            connection.Setup(c => c.Get <IList <Template> >(ApiUrls.TemplatesList(), null))
            .ReturnsAsync(() =>
            {
                var json = System.IO.File.ReadAllText("./Fixtures/Templates_ListTemplates.json");
                return(JsonConvert.DeserializeObject <IList <Template> >(json));
            });

            var templateClient = new TemplatesClient(connection.Object);
            var templates      = await templateClient.List();

            var template = templates.FirstOrDefault(t => t.OS == "Windows 10 (Server 2016) - Licensed");

            var machinesClient = new MachinesClient(connection.Object);
            var result         = await machinesClient.Create(new CreateMachineRequest()
            {
                Region      = Region.EastCoast_NY2,
                MachineType = MachineType.Air,
                Size        = 50,
                BillingType = BillingType.Hourly,
                MachineName = "My Machine 1",
                TemplateId  = template.Id,
            });

            Assert.AreEqual(result.Id, "pslwpsvsx");
        }