Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:25:13+00:00 2026-06-03T16:25:13+00:00

Since F# records are really sealed classes, i cannot stub a record type. Is

  • 0

Since F# records are really sealed classes, i cannot stub a record type. Is there an attribute i can put on a record in F# so that it is not compiled as sealed so that i can stub the record?

type Quote = {a:string}

mock<Quote>

this throws

System.TypeLoadException : Could not load type
‘Castle.Proxies.QuoteProxy’ from assembly ‘DynamicProxyGenAssembly2,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ because the
parent type is sealed.

And if you’re curious. This is the definition for mock:

let mock<'typee when ^typee : not struct> = Substitute.For<'typee>()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:25:16+00:00Added an answer on June 3, 2026 at 4:25 pm

    I don’t think there is a way to tell the F# compiler to generate F# record as a non-sealed class.

    However, the question is, why do you want to stub a record? My understanding is that stubs are used to mimick some functionality of a type. However F# records are generated by the compiler, so if you trust the F# compiler, you should not need to mock them, because they will always behave predictably.

    If you want to add some members to the record, then you can mock these. To do that you can define an interface, implement it in the record type and generate stub for the interface:

    type IFoo = 
      abstract Foo : int -> int
    
    type Bar = 
      { Number : int }
      interface IFoo with
        member x.Foo(n) = n + x.Number
    

    In general, code written in a functional style can be tested just by checking whether an operation gives the correct result for a specified inputs. Testing that the internal implementation invokes some other operation (i.e. using stubs) is less needed. Of course, that probably does not always apply in real-world scenario where you interop with other components…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since DBs do not reuse numbers of deleted records it is possible to run
Since Eclipse 3.5 there seems to be no option to have drop a plugin
Since Microsoft created MSTest, I've been using it for unit testing. I never really
Since enumeration uses integers, what other structure can I use to give me enum-like
I am trying to figure out how to display a count for records that
I am writing a program that needs to read a set of records that
I know there a similar threads around, but this is really the first time
I'm building from scratch a web application that is not trivial (have some algorithms
I'm developing an application that needs to store lots of records in an organized
I'm interested in making an immutable class that has properties that cannot be modified,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.