-
Notifications
You must be signed in to change notification settings - Fork 21
Description
type AccidentDataModel (accidentId,displayText,code) as self =
inherit FSharp.ViewModule.ViewModelBase()
let accidentId = self.Factory.Backing (<@ self.AccidentID @>, accidentId)
let displayText = self.Factory.Backing (<@ self.DisplayText @>, displayText)
let code = self.Factory.Backing (<@ self.Code @>, code)
new () = AccidentDataModel(0,String.Empty,String.Empty)
member x.AccidentID with get() = accidentId.Value and set v = accidentId.Value <- v
member x.DisplayText with get() = displayText.Value and set v = displayText.Value <- v
member x.Code with get() = code.Value and set v = code.Value <- v
Succeeding test
open global.Xunit
open FsCheck
open FsCheck.Xunit
[<Property>]
let createAccidentModelTest x y z =
let model = Pm.Dal.DataModels.AccidentDataModel(x,y,z)
Assert.NotNull model
Assert.Equal(x,model.AccidentID)
Assert.Equal(y, model.DisplayText)
Assert.Equal(z, model.Code)
Failing test for both cases 1, and 100
[<Theory>]
[<InlineData(1)>]
[<InlineData(100)>]
let createAccidentList length =
//generate a single instance of 't
let generateOne() = FsCheck.Arb.generate<'a>.Sample(1,1) |> Seq.head
let generateAdm () = Pm.Dal.DataModels.AccidentDataModel(generateOne() , generateOne(), generateOne())
let items =
[0..length-1]
|> Seq.map (ignore >> generateAdm)
|> Array.ofSeq
Assert.NotNull items
Assert.Equal(items.Length,length)
exception
Test Name: Pm.Tests.IntegrationTests.IntegrationTestModule+DataAccess+Accidents.createAccidentList(length: 100)
Test FullName: Pm.Tests.IntegrationTests.IntegrationTestModule+DataAccess+Accidents.createAccidentList
Test Source: C:\TFS\PracticeManagement\dev\PracticeManagement\Pm.Tests\Integration.XUnit.fs : line 263
Test Outcome: Failed
Test Duration: 0:00:00.229Result StackTrace:
at Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicFunctions.FailInit()
at FSharp.ViewModule.Internal.ViewModelUntyped.Validate(String propertyName)
at FSharp.ViewModule.ValidationTracker.validatePropertiesInternal(String propertyName)
Result Message: System.InvalidOperationException : The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized.