using System;
using System.Threading;
using System.Threading.Tasks;
This example example includes a call to the Task.Wait method to ensure that the task completes execution before the console mode application ends.
public class Example
{
public static void Main()
{
Thread.CurrentThread.Name = "Main";
// Create a task and supply a user delegate by using a lambda expression.
Task taskA = new Task( () => Console.WriteLine("Hello from taskA."));
// Start the task.
taskA.Start();
// Output a message from the calling thread.
Console.WriteLine("Hello from thread '{0}'.",
Thread.CurrentThread.Name);
taskA.Wait();
}
}
// The example displays the following output:
// Hello from thread 'Main'.
// Hello from taskA.
There are basicaly two ways to add multiple new users to a mailing list:
import a list:
http://kb.mailchimp.com/article/how-do-i-create-and-import-my-list
or to use the provided MailChimp-API:
for .net the are API-Wrappers (https://github.com/danesparza/MailChimp.NET, or https://github.com/danesparza/MailChimp.NET) available which makes the MailChimp-API easy to use. In the end its just about manipulating an object and passing it to a method.
MailChimpManager mc = new MailChimpManager("6e0fc756762e0234f06bfa27f5bbe-us7");
EmailParameter email = new EmailParameter(){ Email = txt_Mail.Text };
Dictionary attributes = new Dictionary();
attributes.Add("FNAME", txt_FirstName.Text);
attributes.Add("LNAME", txt_LastName.Text);
EmailParameter results = mc.Subscribe(Util.GetMailchimpListID(), email, attributes);
NUnit is an unit testing framework for the .Net framework and is based on JUnit.
Minimal setup:
For making a test case, a normal c# class is created, which imports the NUnit framework.
using NUnit.Framework
The class must have the attribute [TextFixture] to indicate, that this class has test code.
The attributes [SetUp] and [TearDown] are optional and can be used if some pre/post conditions are need for each test (e.g. resetting the DB).
The different test cases are marked by the attribute [Test]. Different static methods of the Assert class are used for checking the results.
Example:
[TextFixture]
public class MyTests
{
[SetUp]
public void setup()
{
//fill database with test data
}
[TearDown]
public void tearDown()
{
//delete data in database
}
[Test]
public void test1()
{
user = ... //search for user by id
Assert.AreEqual(name, user.name);
}
}