CodeKeep C# Feed Agosto 22nd, 2008
Description: NhibernateGenerateSQL
Link:
http://www.codekeep.net/snippets/78d2109d-964d-4920-9c6a-65699627a87b.aspx [TestFixture]
public class CreateSchemeFixutre
{
private Configuration _cfg;
[Test]
public void CheckMap_ByCreate_A_DatabaseSchemaScript()
{
_cfg = new Configuration();
_cfg.Configure();
var export = new SchemaExport(_cfg);
var sb = new StringBuilder();
TextWriter output = new StringWriter(sb);
export.Execute(true, false, false, false, null, output);
Assert.IsFalse(string.IsNullOrEmpty( sb.ToString() ));
}
}
CodeKeep C# Feed Agosto 22nd, 2008
Description: HowOldAreYou()
Link:
http://www.codekeep.net/snippets/19496e20-8cb3-4468-b196-263dda2b3a91.aspx public string HowOldAreYou()
{
DateTime birthDayThisYear = new DateTime(DateTime.Today.Year,monthBirth,dayBirth);
int years = DateTime.Today.Year - yearBirth;
int months = DateTime.Today.Month - monthBirth;
int days = DateTime.Today.Day - dayBirth;
if(birthDayThisYear==DateTime.Today)
{
return "HAPPY BIRTHDAY TO YOU ....\n You just turned " + years.ToString() + " years old";
}
if(birthDayThisYear > DateTime.Today)//you've not yet celebrated your birthday this year
{
years -= 1;
months += 12;
}
if(birthDayThisYear.Day > DateTime.Today.Day)
{
months -= 1;
DateTime dt = new DateTime(birthDayThisYear.Year,DateTime.Today.Month -1,birthDayThisYear.Day);
TimeSpan ts = DateTime.Today - dt;
days = ts.Days;
}
return "You have " + years.ToString() + " years, " + months.ToString() + " months and " + days.ToString() + " days";
}