Permalink
Browse files

initial checkin

  • Loading branch information...
0 parents commit 4ae13b7343cb4ef791c54b642d2f80ff75f2265e @smichelotti committed Jun 21, 2012
Showing 671 changed files with 597,645 additions and 0 deletions.
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
@@ -0,0 +1,163 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Rr]elease/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# Installshield output folder
+[Ee]xpress
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+Generated_Code #added for RIA/Silverlight projects
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Python
+#############
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+# Mac crap
+.DS_Store
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
+## Web API Demo
+
+This repository contains sample code, PowerPoint, and documentation for my ASP.NET Web API presentation. It includes the before and after code.
+
+### Presentation Abstract
+
+Modern web applications have seen an explosion in Web API creation. Twitter, Facebook, Google, Azure, you name it - it is becoming essential to provide a Web API so that consumers can build applications and mashups on top of your services. Web 2.0 has shown a trend away from SOAP towards a REST architecture style. With the new ASP.NET Web API, Microsoft is now providing first-class support for HTTP services including tools to apply the richness of a REST architectural style. This demo heavy presentation will show how the new ASP.NET Web API will enable you to build rich HTTP services in a REST architectural style while leveraging custom media types, custom HTTP handlers, jQuery and more! The presentation will also cover new features of MVC 4 including Razor enhancements, support for mobile apps, and single page applications.
@@ -0,0 +1,17 @@
+# Shut down unneeded processes
+#PrepareDemoEnvironment
+
+# First clean the target directory
+#Get-ChildItem C:\development\demo\WebApi -recurse | Remove-Item -Recurse -Force
+
+# Copy Snippets
+$ScriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
+
+copy-item $ScriptDir\snippets\WebApi-CSSnippets -Destination "$env:userprofile\Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets" -Recurse -Force
+copy-item $ScriptDir\snippets\WebApi-HtmlSnippets -Destination "$env:userprofile\Documents\Visual Studio 2012\Code Snippets\Visual Web Developer\My HTML Snippets" -Recurse -Force
+copy-item $ScriptDir\snippets\WebApi-JSSnippets -Destination "$env:userprofile\Documents\Visual Studio 2012\Code Snippets\Visual Web Developer\My JScript Snippets" -Recurse -Force
+
+#copy-item $ScriptDir\src\Begin\WebApiDemo -Destination C:\development\demo\WebApi\WebApiDemo -Recurse -Force
+
+#Start-Process -FilePath C:\development\demo\WebApi\WebApiDemo\WebApiDemo.sln
+#Start-Process -FilePath "$ScriptDir\docs\WebAPI.pptx"
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ <Title>wapi1-repo</Title>
+ <Author>setup</Author>
+ <Description>
+ </Description>
+ <HelpUrl>
+ </HelpUrl>
+ <Shortcut>wapi1-repo</Shortcut>
+ </Header>
+ <Snippet>
+ <Code Language="csharp"><![CDATA[private static Dictionary<int, Contact> repository = new Dictionary<int, Contact>
+ {
+ { 1, new Contact { Id = 1, FirstName = "Joe", LastName = "Blow" } },
+ { 2, new Contact { Id = 2, FirstName = "John", LastName = "Doe" } }
+ };]]></Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ <Title>wapi10-csvmediatype</Title>
+ <Author>setup</Author>
+ <Description>
+ </Description>
+ <HelpUrl>
+ </HelpUrl>
+ <Shortcut>wapi10-csvmediatype</Shortcut>
+ </Header>
+ <Snippet>
+ <Code Language="csharp"><![CDATA[public override void WriteToStream(Type type, object value, Stream stream, HttpContentHeaders contentHeaders)
+ {
+ using (var writer = new StreamWriter(stream))
+ {
+ var list = value as IEnumerable;
+ if (list != null)
+ {
+ foreach (var item in list)
+ {
+ WriteItem(item, writer);
+ }
+ }
+ else
+ {
+ WriteItem(value, writer);
+ }
+ }
+ stream.Close();
+ }
+
+ private void WriteItem(object item, StreamWriter writer)
+ {
+ var properties = item.GetType().GetProperties();
+ var line = string.Join(",", properties.Select(p => Convert.ToString(p.GetValue(item))).ToArray());
+ writer.WriteLine(line);
+ }]]></Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ <Title>wapi12-getunittest</Title>
+ <Author>setup</Author>
+ <Description>
+ </Description>
+ <HelpUrl>
+ </HelpUrl>
+ <Shortcut>wapi12-getunittest</Shortcut>
+ </Header>
+ <Snippet>
+ <Code Language="csharp"><![CDATA[using System;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Web.Http;
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Ninject;
+using WebApiDemo;
+using WebApiDemo.Controllers;
+using WebApiDemo.Models;
+
+namespace WebApiDemo.Tests
+{
+ [TestClass]
+ public class TagsControllerTests
+ {
+ [TestMethod]
+ public void Get_all_should_return_tags_list()
+ {
+ // arrange
+ var tagsRepository = new Mock<ITagRepository>();
+ var tagsList = TestUtil.CreateTagsList();
+ tagsRepository.Setup(c => c.GetAll()).Returns(tagsList);
+
+ // act
+ var controller = new TagsController(tagsRepository.Object);
+ var result = controller.GetAll();
+
+ // assert
+ result.Count().Should().Be(8);
+ result.First().Name.Should().Be("Ball Handling");
+ tagsRepository.VerifyAll();
+ }
+ }
+}
+]]></Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ <Title>wapi13-postunittest</Title>
+ <Author>setup</Author>
+ <Description>
+ </Description>
+ <HelpUrl>
+ </HelpUrl>
+ <Shortcut>wapi13-postunittest</Shortcut>
+ </Header>
+ <Snippet>
+ <Code Language="csharp"><![CDATA[[TestMethod]
+ public void Post_valid_tag_should_return_with_location_header()
+ {
+ // arrange
+ var tagsRepository = new Mock<ITagRepository>();
+ var tag = TestUtil.CreateValidTag();
+ tagsRepository.Setup(r => r.InsertOrUpdate(tag)).Callback(() => tag.Id = 1);
+ var kernel = new StandardKernel();
+ kernel.Bind<ITagRepository>().ToMethod(context => tagsRepository.Object);
+
+ var config = new HttpConfiguration();
+ WebApiConfig.Configure(config, new NinjectDependencyResolver(kernel));
+ var server = new HttpServer(config);
+ var client = new HttpClient(server);
+
+ // act
+ var response = client.PostAsJsonAsync<Tag>("http://localhost/api/tags", tag).Result;
+ Console.WriteLine(response.Content.ReadAsStringAsync().Result);
+
+ // assert
+ response.Should().NotBeNull();
+ response.StatusCode.Should().Be(HttpStatusCode.Created);
+ var postedTag = response.Content.ReadAsAsync<Tag>().Result;
+ postedTag.Id.Should().NotBe(0);
+ postedTag.Name.Should().NotBeNull();
+ Console.WriteLine(response.Headers.Location.AbsoluteUri);
+ response.Headers.Location.AbsoluteUri.Should().NotBeNull();
+ }]]></Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
Oops, something went wrong.

0 comments on commit 4ae13b7

Please sign in to comment.