Permalink
Browse files

Merging in latest mainline, I am going to keep on top of other change…

…s this time
  • Loading branch information...
2 parents 4e5913f + 3f91bc3 commit 8bc9c878f0b7443ee5ef7ee645bf9dd42f7b47a5 @stimms stimms committed Jul 23, 2010
@@ -212,14 +212,19 @@ public static List<Constraint> ToConstraintList(this object value)
else if(currentField.FieldType == typeof(Guid))
{
currentField.SetValue(item, rdr.GetGuid(i));
- }
- else if (Objects.IsNullableEnum(currentField.FieldType))
- {
- var nullEnumObjectValue = Enum.ToObject(Nullable.GetUnderlyingType(currentField.FieldType), rdr.GetValue(i));
- currentField.SetValue(item, nullEnumObjectValue);
- }
- else
- currentField.SetValue(item, rdr.GetValue(i).ChangeTypeTo(valueType));
+ } else if (Objects.IsNullableEnum(currentField.FieldType)) {
+ var nullEnumObjectValue = Enum.ToObject(Nullable.GetUnderlyingType(currentField.FieldType), rdr.GetValue(i));
+ currentField.SetValue(item, nullEnumObjectValue);
+ } else {
+ var val = rdr.GetValue(i);
+ var valType = val.GetType();
+ //try to assign it
+ if (currentField.FieldType.IsAssignableFrom(valueType)) {
+ currentField.SetValue(item, val);
+ } else {
+ currentField.SetValue(item, val.ChangeTypeTo(currentField.FieldType));
+ }
+ }
}
}
@@ -16,6 +16,8 @@
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
+
+
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -229,7 +231,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
- <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.
@@ -0,0 +1,42 @@
+//
+// SubSonic - http://subsonicproject.com
+//
+// The contents of this file are subject to the New BSD
+// License (the "License"); you may not use this file
+// except in compliance with the License. You may obtain a copy of
+// the License at http://www.opensource.org/licenses/bsd-license.php
+//
+// Software distributed under the License is distributed on an
+// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+// implied. See the License for the specific language governing
+// rights and limitations under the License.
+//
+using System;
+using SubSonic.Extensions;
+using Xunit;
+using System.Linq;
+
+namespace SubSonic.Tests.Unit.Extensions {
+
+ class Duck {
+ public short Shorty { get; set; }
+ public int Thirty { get; set; }
+
+ }
+ public class Converters {
+
+ [Fact]
+ public void Can_convert_valid_Int32_to_16() {
+
+ var duck = new Duck();
+ duck.Shorty = 12;
+ duck.Thirty = 20;
+
+ var newShort = duck.Thirty.ChangeTypeTo(duck.Shorty.GetType());
+
+ Assert.Equal(typeof(short), newShort.GetType());
+
+ typeof(Duck).GetProperty("Shorty").SetValue(duck, newShort,null);
+ }
+ }
+}
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Xunit;
+using SubSonic.Extensions;
+
+namespace SubSonic.Tests.Unit.Extensions {
+ public class InflectorTests {
+
+ [Fact]
+ public void SomethingStatus_Should_Be_Left_Alone() {
+ var word = "SomethingStatus";
+ var inflected = Inflector.MakeSingular(word);
+ Assert.Equal(word, inflected);
+ }
+
+ [Fact]
+ public void Penis_Should_Be_Pluralized_Penises() {
+ var word = "Person";
+ var inflected = Inflector.MakePlural(word);
+ Assert.Equal("People", inflected);
+ }
+ }
+}
@@ -124,6 +124,8 @@
<ItemGroup>
<None Include="App.config" />
<Compile Include="DataProviders\ProviderFactoryTests.cs" />
+ <Compile Include="Extensions\Converters.cs" />
+ <Compile Include="Extensions\InflectorTests.cs" />
<Compile Include="Linq\SqlStrings\MySqlDateTestsSql.cs" />
<Compile Include="Linq\SqlStrings\MySqlNumberTestsSql.cs" />
<Compile Include="Linq\SqlStrings\MySqlSelectTestsSql.cs" />
@@ -46,7 +46,10 @@ public void Any_Should_Not_Fail()
public void Contains_With_Subquery()
{
var result =
- _db.Customers.Where(c => _db.Orders.Select(o => o.CustomerID).Contains(c.CustomerID));
+ _db.Customers
+ .Where(c => _db.Orders
+ .Select(o => o.CustomerID)
+ .Contains(c.CustomerID));
Assert.Equal(5, result.Count());
}

0 comments on commit 8bc9c87

Please sign in to comment.