Exemplo n.º 1
0
        public void AddsUserToAirtableTable()
        {
            var expectedResponse = new AirtableResponseBuilder()
                                   .AddRecord(
                "rec4rdaOkafgV1Bqm",
                new DateTime(2019, 8, 22, 8, 25, 28)
                ).WithName("Team Performance: Team Agile-Lean maturity 'measures' in practice (at DfE and Hackney)")
                                   .WithHost("Barry")
                                   .WithCategories("Delivery")
                                   .WithTime(2019, 10, 18, 13, 0, 0)
                                   .WithDurationInSeconds(3600)
                                   .WithLocation("Everest, 2nd Foor")
                                   .WithSessionType("Seminar")
                                   .WithAttendees(new List <string>())
                                   .Build();

            airtableSimulator.SetUpFind(TABLE_ID, AIRTABLE_API_KEY, expectedResponse.Records[0], "ID000");
            airtableSimulator.SetUpSave(TABLE_ID, AIRTABLE_API_KEY);

            AirtableGateway                 gateway = new AirtableGateway(AIRTABLE_URL, AIRTABLE_API_KEY, TABLE_ID);
            ToggleWorkshopAttendance        attend  = new ToggleWorkshopAttendance(gateway, gateway);
            ToggleWorkshopAttendanceRequest payload = new ToggleWorkshopAttendanceRequest();

            payload.User       = "******";
            payload.WorkshopId = "ID000";
            attend.Execute(payload);

            var requests = airtableSimulator.simulator.ReceivedRequests;

            Console.WriteLine(requests);
            var sentEmployee = requests[1].BodyAs <AirtableRequest>();

            Assert.AreEqual("Maria", sentEmployee.Records[0].Fields.Attendees[0]);
        }
        public void CanFindWorkshopByID()
        {
            var expectedResponse = new AirtableResponseBuilder()
                                   .AddRecord(
                "rec4rdaOkafgV1Bqm",
                new DateTime(2019, 8, 22, 8, 25, 28)
                ).WithName("Team Performance: Team Agile-Lean maturity 'measures' in practice (at DfE and Hackney)")
                                   .WithHost("Barry")
                                   .WithCategories("Delivery")
                                   .WithTime(2019, 10, 18, 13, 0, 0)
                                   .WithDurationInSeconds(3600)
                                   .WithLocation("Everest, 2nd Foor")
                                   .WithSessionType("Seminar")
                                   .Build();

            airtableSimulator.SetUpFind(TABLE_ID, AIRTABLE_API_KEY, expectedResponse.Records[0], "rec4rdaOkafgV1Bqm");

            AirtableGateway airtableGateway = new AirtableGateway(AIRTABLE_URL, AIRTABLE_API_KEY, TABLE_ID);
            Workshop        workshop        = airtableGateway.Find("rec4rdaOkafgV1Bqm");

            Assert.AreEqual(workshop.name, "Team Performance: Team Agile-Lean maturity 'measures' in practice (at DfE and Hackney)");
            Assert.AreEqual(workshop.host, "Barry");
            Assert.AreEqual(workshop.time, new DateTime(2019, 10, 18, 13, 0, 0));
            Assert.AreEqual(workshop.location, "Everest, 2nd Foor");
            Assert.AreEqual(workshop.type, "Seminar");
            Assert.AreEqual(workshop.duration, 3600 / 60);
        }