Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: gokhanartuk on Dec 13th, 2012  |  syntax: C#  |  size: 1.56 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Part 1 - The Controller Site
  2. // Installed pacakages are DotnetOpenAuth.Aspnet, Microsoft.AspNet.WebPages.OAuth
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web.Mvc;
  8. using DotNetOpenAuth.AspNet.Clients;
  9. using Microsoft.Web.WebPages.OAuth;
  10.  
  11. namespace MvcApplication2.Controllers
  12. {
  13.     public class HomeController : Controller
  14.     {
  15.         private static Dictionary<string, AuthenticationClientData> _authenticationClients = new Dictionary<string, AuthenticationClientData>(StringComparer.OrdinalIgnoreCase);
  16.  
  17.         public ActionResult Index()
  18.         {
  19.             var client = new GoogleOpenIdClient();
  20.             var clientData = new AuthenticationClientData(client,
  21.                                                           "Google", new Dictionary<string, object>());
  22.  
  23.             if (_authenticationClients.Any(q => q.Key == client.ProviderName) == false)
  24.                 _authenticationClients.Add(client.ProviderName, clientData);
  25.  
  26.             return Content("Success");
  27.         }
  28.  
  29.     }
  30. }
  31.  
  32. // Part 2 - The Test Site
  33.  
  34. using System.Web.Mvc;
  35. using Microsoft.VisualStudio.TestTools.UnitTesting;
  36. using MvcApplication2.Controllers;
  37.  
  38. namespace MvcApplication2.Tests
  39. {
  40.  
  41.     [TestClass]
  42.     public class ControllerTest
  43.     {
  44.         [TestMethod()]
  45.         public void should_return_not_empty_content()
  46.         {
  47.             var controller = new HomeController();
  48.             var result = controller.Index() as ContentResult;            
  49.  
  50.             Assert.IsNotNull(result.Content);
  51.         }
  52.  
  53.     }
  54. }