Esempio n. 1
0
    public void ShouldConvertMailjetMessageToCorrectJson()
    {
        var options = new MailjetOptions
        {
            ApiKeyPublic         = "",
            ApiKeyPrivate        = "",
            IsSendingMailAllowed = true,
        };

        var client = new MailjetService(options);

        var mailjetMail = new MailjetMail()
        {
            Users = new List <User> {
                new User {
                    Email = "*****@*****.**"
                }
            },
            Variables = new NestedClass
            {
                I = 42,
                S = "toto"
            }
        };

        var converted = client.ConvertToMailjetMessage(mailjetMail);

        var json = JObject.FromObject(converted);

        Assert.Equal("toto", json["Variables"]?["field"]?.Value <string>());
        Assert.Equal(42, json["Variables"]?["I"]?.Value <int>());
        Assert.Equal("*****@*****.**", json["To"]?[0]?["Email"]?.Value <string>());
        Assert.False(json.ContainsKey("From"));
    }
Esempio n. 2
0
    public void ShoulConvertToCorrectMailjetEntity()
    {
        var options = new MailjetOptions
        {
            ApiKeyPublic         = "",
            ApiKeyPrivate        = "",
            IsSendingMailAllowed = true
        };

        var client = new MailjetService(options);

        var mailjetMail = new MailjetMail()
        {
            Users = new List <User> {
                new User {
                    Email = "*****@*****.**"
                }
            },
        };

        var converted = client.ConvertToMailjetMessage(mailjetMail);

        Assert.Null(converted.From);
        Assert.IsType <List <MailjetMailUser> >(converted.To);
        Assert.Equal("*****@*****.**", converted.To[0].Email);
    }