コード例 #1
0
        public void ConvertsAndMaintainsProperties()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);
            var attendee   = new Attendee
            {
                Id      = "1428494963",
                Profile = new AttendeeProfile
                {
                    Gender    = "female",
                    Name      = "Jonathon Spice",
                    Addresses = new Addresses
                    {
                        Ship = new Address
                        {
                            City       = "Sheffield",
                            Region     = "South Yorkshire",
                            PostalCode = "S61rt",
                            Address1   = "5 Eastgate",
                            Country    = "GB"
                        }
                    },
                    Email     = "*****@*****.**",
                    FirstName = "Jonathon",
                    LastName  = "Spice"
                }
            };

            var entrant = serialiser.ConvertEntrant(attendee);

            Assert.Equal(attendee.Id, entrant.EventbriteId);
            Assert.Equal(attendee.Profile.Name, entrant.Name);
            Assert.Equal(attendee.Profile.Email, entrant.Email);
            Assert.Equal(attendee.Profile.Gender, entrant.BioGender.ToString().ToLower());
            Assert.Equal(JsonSerializer.Serialize(attendee.Profile.Addresses.Ship), JsonSerializer.Serialize(entrant.Address));
        }
コード例 #2
0
ファイル: Webhook.cs プロジェクト: Vespion/AquaShine
 public Webhook(ApiSerialiser apiSerialiser, ApiClient apiClient, IDataContext dataContext, IMailClient smtpClient, IOptions <EmailConfig> emailOptions)
 {
     _apiSerialiser = apiSerialiser;
     _apiClient     = apiClient;
     _dataContext   = dataContext;
     _smtpClient    = smtpClient;
     _emailOptions  = emailOptions;
 }
コード例 #3
0
        public void ThrowsExceptionWhenMissingProperties()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);

            var exception = Assert.Throws <JsonException>(() => serialiser.DeserialiseWebhookPayload(InvalRowKeyJson));

            Assert.StartsWith(StatusCodes.MissingJsonProperty.ToString(), exception.Message);
        }
コード例 #4
0
        public void DecodesWebhookPayload()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);

            var webhookBody1 = serialiser.DeserialiseWebhookPayload(WebhookJson1);

            Assert.Equal(new Uri(@"https://www.eventbriteapi.com/v3/orders/1428494963/"), webhookBody1.ApiUrl);
            Assert.Equal(@"order.placed", webhookBody1.Action);
        }
コード例 #5
0
        public void ThrowsExceptionWhenNull()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);

            var exception = Assert.Throws <ArgumentNullException>(() => serialiser.ConvertEntrant(null));
        }
コード例 #6
0
        public void ThrowsExceptionWhenCorrupt()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);

            Assert.ThrowsAny <JsonException>(() => serialiser.DeserialiseWebhookPayload(CorruptJson));
        }
コード例 #7
0
        public void EntrantRowKeysDoNotRepeat()
        {
            var serialiser = new ApiSerialiser(_RowKeyGenerator);
            var attendee   = new Attendee
            {
                Id      = "1428494963",
                Profile = new AttendeeProfile
                {
                    Gender    = "female",
                    Name      = "Jonathon Spice",
                    Addresses = new Addresses
                    {
                        Ship = new Address
                        {
                            City       = "Sheffield",
                            Region     = "South Yorkshire",
                            PostalCode = "S61rt",
                            Address1   = "5 Eastgate",
                            Country    = "GB"
                        }
                    },
                    Email     = "*****@*****.**",
                    FirstName = "Jonathon",
                    LastName  = "Spice"
                }
            };

            var entrant   = serialiser.ConvertEntrant(attendee);
            var entrant2  = serialiser.ConvertEntrant(attendee);
            var entrant3  = serialiser.ConvertEntrant(attendee);
            var entrant4  = serialiser.ConvertEntrant(attendee);
            var entrant5  = serialiser.ConvertEntrant(attendee);
            var entrant6  = serialiser.ConvertEntrant(attendee);
            var entrant7  = serialiser.ConvertEntrant(attendee);
            var entrant8  = serialiser.ConvertEntrant(attendee);
            var entrant9  = serialiser.ConvertEntrant(attendee);
            var entrant10 = serialiser.ConvertEntrant(attendee);

            Assert.NotEqual(entrant.RowKey, entrant2.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant3.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant4.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant5.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant6.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant7.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant8.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant9.RowKey);
            Assert.NotEqual(entrant.RowKey, entrant10.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant3.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant4.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant5.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant6.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant7.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant8.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant9.RowKey);
            Assert.NotEqual(entrant2.RowKey, entrant10.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant2.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant3.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant4.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant7.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant6.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant7.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant8.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant9.RowKey);
            Assert.NotEqual(entrant5.RowKey, entrant10.RowKey);
        }