Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #5

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# 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
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
<<<<<<< HEAD
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
=======
*.suo
**/bin/**/*
**/obj/**/*
>>>>>>> 6241f30808bd880c1381f9733f1894c51b79e796
2 changes: 1 addition & 1 deletion AutoKoanRunner.Core/KoanSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public class KoanSource
SourceFolder = @"..\..\..\VBNet",
AssemblyPath = @"..\..\..\VBNet\bin\debug\VBNet.dll"
};
public static readonly KoanSource[] Sources = new[] { CSharp, VBasic };
public static readonly KoanSource[] Sources = new[] { CSharp };
}
}
8 changes: 4 additions & 4 deletions CSharp/AboutArrayAssignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void ImplicitAssignment()
//Even though we don't specify types explicitly, the compiler
//will pick one for us
var name = "John";
Assert.Equal(typeof(FillMeIn), name.GetType());
Assert.Equal(typeof(string), name.GetType());

//but only if it can. So this doesn't work
//var array = null;
Expand All @@ -36,7 +36,7 @@ public void ImplicitArrayAssignmentWithSameTypes()
//Even though we don't specify types explicitly, the compiler
//will pick one for us
var names = new[] { "John", "Smith" };
Assert.Equal(typeof(FillMeIn), names.GetType());
Assert.Equal(typeof(string[]), names.GetType());

//but only if it can. So this doesn't work
//var array = new[] { "John", 1 };
Expand All @@ -48,8 +48,8 @@ public void MultipleAssignmentsOnSingleLine()
//You can do multiple assignments on one line, but you
//still have to be explicit
string firstName = "John", lastName = "Smith";
Assert.Equal(FILL_ME_IN, firstName);
Assert.Equal(FILL_ME_IN, lastName);
Assert.Equal("John", firstName);
Assert.Equal("Smith", lastName);
}
}
}
32 changes: 16 additions & 16 deletions CSharp/AboutArrays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class AboutArrays : Koan
public void CreatingArrays()
{
var empty_array = new object[] { };
Assert.Equal(typeof(FillMeIn), empty_array.GetType());
Assert.Equal(typeof(object[]), empty_array.GetType());

//Note that you have to explicitly check for subclasses
Assert.True(typeof(Array).IsAssignableFrom(empty_array.GetType()));

Assert.Equal(FILL_ME_IN, empty_array.Length);
Assert.Equal(0, empty_array.Length);
}

[Koan(2)]
Expand All @@ -29,13 +29,13 @@ public void ArrayLiterals()
Assert.Equal(new int[] { 42 }, array);

//Are arrays 0-based or 1-based?
Assert.Equal(42, array[((int)FILL_ME_IN)]);
Assert.Equal(42, array[((int)0)]);

//This is important because...
Assert.True(array.IsFixedSize);

//...it means we can't do this: array[1] = 13;
Assert.Throws(typeof(FillMeIn), delegate() { array[1] = 13; });
Assert.Throws(typeof(IndexOutOfRangeException), delegate() { array[1] = 13; });

//This is because the array is fixed at length 1. You could write a function
//which created a new array bigger than the last, copied the elements over, and
Expand All @@ -45,16 +45,16 @@ public void ArrayLiterals()
Assert.Equal(array, dynamicArray.ToArray());

dynamicArray.Add(13);
Assert.Equal((new int[] { 42, (int)FILL_ME_IN}), dynamicArray.ToArray());
Assert.Equal((new int[] { 42, (int)13}), dynamicArray.ToArray());
}

[Koan(3)]
public void AccessingArrayElements()
{
var array = new[] { "peanut", "butter", "and", "jelly" };

Assert.Equal(FILL_ME_IN, array[0]);
Assert.Equal(FILL_ME_IN, array[3]);
Assert.Equal("peanut", array[0]);
Assert.Equal("jelly", array[3]);

//This doesn't work: Assert.Equal(FILL_ME_IN, array[-1]);
}
Expand All @@ -64,8 +64,8 @@ public void SlicingArrays()
{
var array = new[] { "peanut", "butter", "and", "jelly" };

Assert.Equal(new string[] { (string)FILL_ME_IN, (string)FILL_ME_IN }, array.Take(2).ToArray());
Assert.Equal(new string[] { (string)FILL_ME_IN, (string)FILL_ME_IN }, array.Skip(1).Take(2).ToArray());
Assert.Equal(new string[] { (string)"peanut", (string)"butter" }, array.Take(2).ToArray());
Assert.Equal(new string[] { (string)"butter", (string)"and" }, array.Skip(1).Take(2).ToArray());
}

[Koan(5)]
Expand All @@ -74,10 +74,10 @@ public void PushingAndPopping()
var array = new[] { 1, 2 };
Stack stack = new Stack(array);
stack.Push("last");
Assert.Equal(FILL_ME_IN, stack.ToArray());
Assert.Equal(new object[] { "last", 2, 1 }, stack.ToArray());
var poppedValue = stack.Pop();
Assert.Equal(FILL_ME_IN, poppedValue);
Assert.Equal(FILL_ME_IN, stack.ToArray());
Assert.Equal("last", poppedValue);
Assert.Equal(new object[] { 2, 1 }, stack.ToArray());
}

[Koan(6)]
Expand All @@ -91,16 +91,16 @@ public void Shifting()
var list = new LinkedList<string>(array);

list.AddFirst("Say");
Assert.Equal(FILL_ME_IN, list.ToArray());
Assert.Equal(new string[] { "Say", "Hello", "World" }, list.ToArray());

list.RemoveLast();
Assert.Equal(FILL_ME_IN, list.ToArray());
Assert.Equal(new string[] { "Say", "Hello" }, list.ToArray());

list.RemoveFirst();
Assert.Equal(FILL_ME_IN, list.ToArray());
Assert.Equal(new string[] { "Hello" }, list.ToArray());

list.AddAfter(list.Find("Hello"), "World");
Assert.Equal(FILL_ME_IN, list.ToArray());
Assert.Equal(new string[] { "Hello", "World" }, list.ToArray());
}

}
Expand Down
9 changes: 5 additions & 4 deletions CSharp/AboutAsserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ public class AboutAsserts : Koan
[Koan(1)]
public void AssertTruth()
{
Assert.True(false); //This should be true
Assert.True(true); //This should be true
}

//Enlightenment may be more easily achieved with appropriate messages
[Koan(2)]
public void AssertTruthWithMessage()
{
Assert.True(false, "This should be true -- Please fix this");
Assert.True(true, "This should be true -- Please fix this");
}

//To understand reality, we must compare our expectations against reality
[Koan(3)]
public void AssertEquality()
{
var expectedValue = 3;
var actualValue = 1 + 1;
var actualValue = 1 + 2;
Assert.True(expectedValue == actualValue);
}

Expand All @@ -32,14 +32,15 @@ public void AssertEquality()
public void ABetterWayOfAssertingEquality()
{
var expectedValue = 3;
var actualValue = 1 + 1;
var actualValue = 1 + 2;
Assert.Equal(expectedValue, actualValue);
}

//Sometimes we will ask you to fill in the values
[Koan(5)]
public void FillInValues()
{
var FILL_ME_IN = 2;
Assert.Equal(FILL_ME_IN, 1 + 1);
}
}
Expand Down
Loading