Round house and powershell

Using https://github.com/chucknorris/roundhouse for powershell to get automated database change management Task UpgradeDatabase{ if (($environment -eq 'integration') -or ($environment -eq 'uat')) { # round house variables $rh = "C:\\dev\\Phoenix\\trunk\\Tools\\RoundhousE\\console\\rh.exe" $connectionString = "Data Source=localhost;Database=XXX; User Id=XXXuser; Password=XXX;Connect Timeout=100;" $indexesFolder = "C:\\dev\\Phoenix\\trunk\\Database\\10-Indexes" $schemaChangesFolder = "C:\\dev\\Phoenix\\trunk\\Database\\11-SchemaChanges" ## build server? if (Test-Path "D:\\Code\\") { $rh = "D:\\Code\\Phoenix\\trunk\\Tools\\RoundhousE\\console\\rh.exe" $indexesFolder = "D:\\Code\\Phoenix\\trunk\\Database\\10-Indexes" $schemaChangesFolder = "D:\\Code\\Phoenix\\trunk\\Database\\11-SchemaChanges" if ($environment -eq 'integration') { $connectionString = "Data Source=xxxxx;Database=rrrr\_Integration; User Id=rrrr; Password=rrrr;" } else { $connectionString = "Data Source=xxxx;Database=rrrrr\_UAT; User Id=rrrrr; Password=rrrrr;" } } Write\-Host "Database upgrade started" $s1 = " -c " $s2 = " $connectionString " $s3 = " -ix " $s4 = "$indexesFolder" $s5 = " -u " $s6 = "$schemaChangesFolder" $args = $s1 + " ""$s2" "" + $s3 + " ""$s4" "" + $s5 + " ""$s6""" + " -ni -ct 300" Write\-Host $args Start-Process -FilePath $rh -ArgumentList $args -PassThru Write\-Host "Database upgrade complete" } } The following tables are created ...

June 2012 · Smart Tech

PSAKE- Gallio–SpecFlow–XUnit–on the build server

This is a quick post to show how to get PowerShell with PSAKE to run Specflow acceptance tests on the build server using Gallio. https://github.com/chrismckelt/PS-Sake-BuildScripts The folder with our build scripts looks like this The environments folder contains all of the configuration files for each environment Build server process The build/check-in process is now as follows. 1. Developer checks in. 2. Build server detects changes – cleans everything and then pulls down latest SVN code ...

November 2011 · Smart Tech

My interview coding test

Technical Test - Book Store An online books store sells books for 3 different categories: Crime, Romance, Fantasy. Currently all books within the Crime category are discounted by 5% Total tax for the whole order is 10% The task Write a simple console application that outputs the total order cost with and without tax for the below purchase: Book name Category Total Cost Unsolved crimes Crime 10.99 A Little Love Story Romance 2.40 Heresy Fantasy 6.80 Jack the Ripper Crime 16.00 The Tolkien Years Fantasy 22.90 Guidelines ...

March 2011 · Smart Tech

Sales Tax Calculator using SpecFlow & The State Pattern And Chained Commands

Using SpecFlow heres how I solved the following problem PROBLEM : SALES TAXES Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty is an additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions._ When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid. The rounding rules for sales tax are that for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax. ...

March 2011 · Smart Tech

Interview Process

Interview Process Pairing Interview This workbook is designed to help focus on the important aspects of the interview. Take as many or as few notes as you need to answer the following questions, and fill in the interview summary: Design What design process did they use before /while building the solution? We are looking to identify the ability decompose the problem into a possible solution. What processes and or tooling did they use? ...

March 2011 · Smart Tech

F# Beginnings

open System #light // Hello world let a = “Hello, world!”; let mutable b = 0; while b < 10 do b <- b+1 Console.WriteLine(a + b.ToString()) Console.ReadLine() |> ignore // recursive binary search - http://rosettacode.org/wiki/Binary_search#F.23 let items = [| 10; 20; 30; 40; 50; 60; 70; 80; 90; 100; |] let rec binarySearch (arr:int[], low:int, high:int, value:int) = if (high < low) then false else let mid = (low + high) / 2 ...

March 2011 · Smart Tech

DatabaseBackup.fs

March 2011 · Smart Tech

Spec Flow, Specifications and Chained Commands

A quick experiment with Spec Flow – http://www.specflow.org/ Spec flow feature Feature: Run Specification rules To stop large postage costs As a user I want to be stopped from buying to much if I am in Australia @CountryAllowedToProcessOrderWithLargeCost Scenario: Orders of 20 cannot be sent to Australia Given I have a customer with an order for socks And the order is to be sent to Australia When I process the order Then I should not be able to place the order ...

October 2010 · Smart Tech

Agile Flavours

XP 5 values 14 principles 12 Primary practices 11 Corollary practices Lean 7 principles 22 thinking tools Scrum 5 Values 3 Roles (Product owner, scrum master, scrum team) 3 Ceremonies (Sprint planning meeting, Stand up, review & retrospective) 3 Work Products (product backlog, sprint backlog, burndown chart) (depending on which definition you choose) DSDM Atern 8 Principles 5 Lifecycle phases 12 roles 17 work products 5 key techniques Agile Unified Process ...

September 2010 · Smart Tech

Custom NHibernate User Type

How to use a custom NHibernate User Type To store the state of a Risk (ie RiskState) as a value in a column we can use a NHibernate.UserType The RiskState can be one of the following: (these are all derived from RiskState which implements IRiskState) Our user type public class RiskStateNameUserType: IUserType { #region IUserType Members public object Assemble(object cached, object owner) { return cached; } public object DeepCopy(object value) { return value; } public object Disassemble(object value) { return value; } public int GetHashCode(object x) { return x.GetHashCode(); } public bool IsMutable { get { return false; } } public object NullSafeGet(System.Data.IDataReader dr, string\[\] names, object owner) { var property0 = NHibernateUtil.String.NullSafeGet(dr, names\[0\]); if (property0 == null) { return null; } IRiskState state; if (owner is Risk) { state = (IRiskState) Activator.CreateInstance(Type.GetType(typeof (IRiskState).Namespace + "." + (string) property0), owner); } else { state = (IRiskState) Activator.CreateInstance(Type.GetType(typeof (IRiskState).Namespace + "." + (string) property0)); } return state; } public void NullSafeSet(System.Data.IDbCommand cmd, object value, int index) { if (value == null) { ((IDataParameter) cmd.Parameters\[index\]).Value = DBNull.Value; } else { var state = (IRiskState) value; ((IDataParameter) cmd.Parameters\[index\]).Value = state.GetType().Name; } } public object Replace(object original, object target, object owner) { return original; } public Type ReturnedType { get { return typeof (RiskState); } } public NHibernate.SqlTypes.SqlType\[\] SqlTypes { get { return new\ [\] { NHibernateUtil.String.SqlType }; } } public new bool Equals(object x, object y) { if (x == null && y == null) return true; if (x == null || y == null) return false; return x.GetType() == y.GetType(); } #endregion } Using this on a property as follows: ...

August 2010 · Smart Tech

Invalid object name 'master.dbo.spt_values'.

“Invalid object name ‘master.dbo.spt_values’.” This means your SQL Master DB is in a bad state. To fix: Error- Invalid object name ‘master.dbo.spt_values’. CD “C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Install” run u_tables.sql in master….

August 2010 · Smart Tech

RhinoMocks – WhenCalled

The following test would fail without this .WhenCalled(invocation => invocation.ReturnValue = new TestResult(){IsTrue = true, Message = "BBB"}) [TestClass] public class ChrisTest { private IRuleService ruleService; [TestMethod] public void ShouldNotChangeReturnedTestResult() { ruleService = MockRepository.GenerateMock<IRuleService>(); var testResult = new TestResult(); testResult.IsTrue = true; testResult.Message = "AAA"; ruleService.Stub(a => a.GetTestResult()).Return(testResult) .WhenCalled(invocation => invocation.ReturnValue = new TestResult(){IsTrue = true, Message = "BBB"}); var testClass = new TestClass(ruleService); testClass.KillTheString(); Assert.IsTrue(testClass.StringIsThere()); } public interface IRuleService { TestResult GetTestResult(); } public class TestResult { public bool IsTrue { get; set; } public string Message { get; set; } } private class TestClass { private readonly IRuleService ruleService; public TestClass(IRuleService ruleService) { this.ruleService = ruleService; } public void KillTheString() { var result = ruleService.GetTestResult(); result.Message = string.Empty; } public bool StringIsThere() { var result = ruleService.GetTestResult(); return !string.IsNullOrEmpty(result.Message); } } }

July 2010 · Smart Tech

Crystal Software Development

Crystal Software Development Download Agile talk

June 2010 · Smart Tech

Integrated Security = SSPI -- Security Support Provider Interface

Using Integrated Security in connection strings should be either of the following: Integrated Security=SSPI or Integrated Security=false Not Integrated Security=true

June 2010 · Smart Tech

LIFO vs FIFO

LIFO FIFO higher COGS lower COGS lower taxes higher taxes lower net income higher net income lower inventory balances higher inventory balances higher cash flows (less tax paid out) lower cash flows (more tax paid out) lower net and gross margins higher net and gross margins lower current ratio higher current ratio higher inventory turnover lower inventory turnover DA and DE higher DA and DE lower Under IFRS the permissible cost flow methods are: Specific Identification FIFO Weighted average cost

June 2010 · Smart Tech

WPF UI Thread Dispatcher

A simple implemention for calling asych methods from the UI Examples dispatcher.ExecuteOnMainUIThread(CommandManager.InvalidateRequerySuggested); dispatcher.Execute(() => { SomeLongRunningMethodHere(); }); The interface public interface IDispatcher { void Execute(Action action); void ExecuteOnMainUIThread(Action action); } } Synchronous for use in Testing public class SynchronousDispatcher: IDispatcher { public void Execute(Action action) { action(); } public void ExecuteOnMainUIThread(Action action) { action(); } } Asynchronous for use by the application at run time public class AsynchronousDispatcher: IDispatcher { public void Execute(Action action) { action.BeginInvoke(CallBack, action); } public void ExecuteOnMainUIThread(Action action) { Dispatcher dispatcher; if (Application.Current != null) { dispatcher = Application.Current.Dispatcher; } else { dispatcher = Dispatcher.CurrentDispatcher; } dispatcher.Invoke(action); } private void CallBack(IAsyncResult result) { try { ((Action) result.AsyncState).EndInvoke(result); } catch (Exception ex) { // Need to raise the exception on the main thread ExecuteOnMainUIThread(() => { throw ex; } ); } finally { result.AsyncWaitHandle.Close(); } } }

May 2010 · Smart Tech

Rhino Mock Constraints -- AssertWasCalled

Rhino Mock Constraints allow use to test a methods parameters were called with the correct arguments. public interface IDocumentService { void Save(string userName, Document document, Stream stream); } Some ways to ensure the method that contains the save method passes the correct internally constructed arguments include documentService.AssertWasCalled(a=>a.Save(“chris”, doc, adaptor.InputStream), b => b.Constraints(Is.Equal(“chris”), Is.NotNull(), Is.AnyThing())); Passing in Property.AllPropertiesMatch(this.MyTestObjectWithPropertiesThatShouldMatch) will check values against each object

May 2010 · Smart Tech

CFA – Accounting Ratios

Liquidity ratios Cash ratio is the same as Quick without the accounts receivable Solvency ratios Long term debt to equity = total debt / total equity Debt to equity = total debt / total equity Total debt ratio = total debt / total assets Financial leverage ratio = total assets / total equity

May 2010 · Smart Tech

Allow IIS7 to download .config files

In the following file C:\\Windows\\System32\\inetsrv\\config\\applicationHost.config Ensure the following <section name\="requestFiltering" overrideModeDefault\="Allow" /> In the Web.Config <?xml version\="1.0" encoding\="UTF-8"?\> <configuration> <system.webServer> <handlers> <add name=“StaticFile” path="*" verb="*" modules=“StaticFileModule,DefaultDocumentModule,DirectoryListingModule” resourceType=“Either” requireAccess=“Read” /> </handlers> <staticContent> <mimeMap fileExtension=".*" mimeType=“application/octet-stream” /> </staticContent> <security> <requestFiltering> <fileExtensions allowUnlisted=“true”> <remove fileExtension=".config" /> <add fileExtension=".config" allowed=“true” /> </fileExtensions> </requestFiltering> </security> </system.webServer> </configuration>

March 2010 · Smart Tech

Stream bytes to files

using(var stream = Assembly.GetAssembly(typeof (StubPolicy)).GetManifestResourceStream( "Documents.TestHelpers.Files.test.msg")) { const int bufferLength = 256; var buffer = new Byte\[bufferLength\]; if (stream != null) { int bytesRead = stream.Read(buffer, 0, bufferLength); using(var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write)) { // Write out the input stream while (bytesRead > 0) { fs.Write(buffer, 0, bytesRead); bytesRead = stream.Read(buffer, 0, bufferLength); } fs.Close(); } stream.Close(); } }

February 2010 · Smart Tech