2

I have been setting up some unit tests for a service which surfaces Dynamics CRM 2011 data via the SDK and using Mocks to simulate the transactions. This works ok for most of the simple transactions, however, now I need to test a method which utilises the RetrieveAttributeRequest message from the SDK to retrieve OptionSetValue labels. To be able to Mock the returned object would require knowledge of exactly how this method is retrieving the attribute data, but I have not been able to find this information.

1) Is this the correct way to approach this problem, or are we left with an integration test as the main option. 2) If this is valid then which table is the data requested from?

Thanks.

Philip Rich
  • 637
  • 1
  • 9
  • 20
  • 2
    `OptionSetValues` are stored in the `StringMap` table, key fields being `AttributeName` (the `OptionSet` field name), `AttributeValue` (the numeric value of the `OptionSetValue`), `Value` (the string value), and `ObjectTypeCode` (the integer identifier of the related entity). – Peter Majeed Jul 12 '12 at 16:39
  • I'd write that up as an answer @PeterMajeed, I think that about covers it! – glosrob Jul 12 '12 at 18:37
  • @glosrob: I think it covers part 2b only, though. :) If this is all the OP needs, I will do. – Peter Majeed Jul 12 '12 at 18:54
  • Thanks for your answer @PeterMajeed. I would be happy to mark that as an answer. I am certainly interested in the first part of the question also as I feel that Dynamics CRM customisations are further pushing the boundaries it can become harder to convince ourselves that our tests are sufficient and it can become more tricky to Mock everything in a satisfactory way without dismantling each SDK message to its roots. – Philip Rich Jul 12 '12 at 20:39
  • @PhilipRich: Thanks for the further clarification. If you really want an answer to the first part of your question, definitely leave my answer "unaccepted"; someone might still be able to provide a better answer in that case. – Peter Majeed Jul 12 '12 at 21:20

2 Answers2

2

To (only!) answer the second part of your question, OptionSetValues are stored in the StringMap table, key fields being AttributeName (the OptionSet field name), AttributeValue (the integer value of the OptionSetValue), Value (the string value), and ObjectTypeCode (the integer identifier of the related entity).

Peter Majeed
  • 5,304
  • 2
  • 32
  • 57
1

For reference: We ended up abstracting our 'GetOptionSetMetadata' method (which utilises the RetrieveAttributeRequest') into a Common interface. Then created a Mock implementation of the method which purely returned a Dictionary representing the Label and Value option set values. That way we circumvent the need to actually mock the specific returned object in the mockServiceContext.

Philip Rich
  • 637
  • 1
  • 9
  • 20