Skip to content

Commit

Permalink
Merge branch 'master' into with-html
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeWitherington committed Dec 4, 2011
2 parents d9cd7f9 + 68614fe commit b5e468c
Show file tree
Hide file tree
Showing 22 changed files with 890 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dotnet/ReportGenerator-CS/Machine.cs
@@ -0,0 +1,37 @@
namespace ReportGeneratorCS
{
public class Machine
{
private string name;
private string bin;
private string location;

public Machine(string name, string location)
{
this.name = name;
this.location = location;
}

public string Take()
{
string result = bin;
bin = null;
return result;
}

public string Bin()
{
return bin;
}

public void Put(string bin)
{
this.bin = bin;
}

public string Name()
{
return name;
}
}
}
39 changes: 39 additions & 0 deletions dotnet/ReportGenerator-CS/Properties/AssemblyInfo.cs
@@ -0,0 +1,39 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("Factory")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Factory")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("2cc2454a-91ba-46ef-b6e5-df8778a52ab8")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
37 changes: 37 additions & 0 deletions dotnet/ReportGenerator-CS/Report.cs
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.IO;

namespace ReportGeneratorCS
{
public class Report
{
public static void report(StringWriter output, IList<Machine> machines, Robot robot)
{
output.Write("FACTORY REPORT\n");

IEnumerator<Machine> line = machines.GetEnumerator();
while (line.MoveNext())
{
Machine machine = line.Current;
output.Write("Machine " + machine.Name());

if (machine.Bin() != null)
output.Write(" bin=" + machine.Bin());

output.Write("\n");
}
output.Write("\n");

output.Write("Robot");
if (robot.Location() != null)
output.Write(" location=" + robot.Location().Name());

if (robot.Bin() != null)
output.Write(" bin=" + robot.Bin());

output.Write("\n");

output.Write("========\n");
}
}
}
58 changes: 58 additions & 0 deletions dotnet/ReportGenerator-CS/ReportGenerator-CS.csproj
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A544A661-A053-404A-BE68-190687ACDEF7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ReportGeneratorCS</RootNamespace>
<AssemblyName>ReportGeneratorCS</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.5.5.10112, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Machine.cs" />
<Compile Include="Report.cs" />
<Compile Include="Tests\ReportTest.cs" />
<Compile Include="Robot.cs" />
<Compile Include="Tests\RobotTest.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
34 changes: 34 additions & 0 deletions dotnet/ReportGenerator-CS/Robot.cs
@@ -0,0 +1,34 @@
namespace ReportGeneratorCS
{
public class Robot
{
private string bin;
private Machine location;

public Machine Location()
{
return location;
}

public void MoveTo(Machine location)
{
this.location = location;
}

public void Pick()
{
bin = location.Take();
}

public string Bin()
{
return bin;
}

public void Release()
{
location.Put(bin);
bin = null;
}
}
}
39 changes: 39 additions & 0 deletions dotnet/ReportGenerator-CS/Tests/ReportTest.cs
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;

namespace ReportGeneratorCS.Tests
{
[TestFixture]
public class ReportTest
{
[Test]
public void TestReport()
{
IList<Machine> line = new List<Machine>();
line.Add(new Machine("mixer", "left"));

Machine extruder = new Machine("extruder", "center");
extruder.Put("paste");
line.Add(extruder);

Machine oven = new Machine("oven", "right");
oven.Put("chips");
line.Add(oven);

Robot robot = new Robot();
robot.MoveTo(extruder);
robot.Pick();

StringWriter output = new StringWriter();
Report.report(output, line, robot);

string expected = "FACTORY REPORT\n"
+ "Machine mixer\nMachine extruder\n"
+ "Machine oven bin=chips\n\n"
+ "Robot location=extruder bin=paste\n" + "========\n";

Assert.That(expected, Is.EqualTo(output.ToString()));
}
}
}
32 changes: 32 additions & 0 deletions dotnet/ReportGenerator-CS/Tests/RobotTest.cs
@@ -0,0 +1,32 @@
using NUnit.Framework;

namespace ReportGeneratorCS.Tests
{
[TestFixture]
public class RobotTest
{
[Test]
public void TestRobot()
{
Machine sorter = new Machine("Sorter", "left");
sorter.Put("chips");
Machine oven = new Machine("Oven", "middle");
Robot robot = new Robot();

Assert.That("chips", Is.EqualTo(sorter.Bin()));
Assert.That(oven.Bin(), Is.Null);
Assert.That(robot.Location(), Is.Null);
Assert.That(robot.Bin(), Is.Null);

robot.MoveTo(sorter);
robot.Pick();
robot.MoveTo(oven);
robot.Release();

Assert.That(robot.Bin(), Is.Null);
Assert.That(oven, Is.EqualTo(robot.Location()));
Assert.That(sorter.Bin(), Is.Null);
Assert.That("chips", Is.EqualTo(oven.Bin()));
}
}
}
30 changes: 30 additions & 0 deletions dotnet/ReportGenerator-VB/Machine.vb
@@ -0,0 +1,30 @@
Namespace ReportGeneratorVB
Public Class Machine
Private _name As String
Private _bin As String
Private _location As String

Public Sub New(ByVal name As String, ByVal location As String)
Me._name = name
Me._location = location
End Sub

Public Function Take() As String
Dim result As String = _bin
_bin = Nothing
Return result
End Function

Public Function Bin() As String
Return _bin
End Function

Public Sub Put(ByVal bin As String)
Me._bin = bin
End Sub

Public Function Name() As String
Return _name
End Function
End Class
End Namespace
13 changes: 13 additions & 0 deletions dotnet/ReportGenerator-VB/My Project/Application.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dotnet/ReportGenerator-VB/My Project/Application.myapp
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>1</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
35 changes: 35 additions & 0 deletions dotnet/ReportGenerator-VB/My Project/AssemblyInfo.vb
@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.

' Review the values of the assembly attributes

<Assembly: AssemblyTitle("ReportGenerator-VB")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Microsoft")>
<Assembly: AssemblyProduct("ReportGenerator-VB")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2011")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("c44edc53-096d-464c-9176-2cd580d14595")>

' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

0 comments on commit b5e468c

Please sign in to comment.