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 8549377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:42:05+00:00 2026-06-11T13:42:05+00:00

I have this first version of a class public class GenerateAuthorisationWorkflows : IGenerateAuthorisationWorkflows {

  • 0

I have this first version of a class

public class GenerateAuthorisationWorkflows : IGenerateAuthorisationWorkflows
{
    public IList<Guid> FromDtaObjects(IList<DtaObject> dtaObjects, Employee requestingEmployee)
    {
        foreach (var dtaObject in dtaObjects) { }
        return new List<Guid>();
    }

    public IList<Guid> FromDtaObjects()
    {
        return new List<Guid>();
    }
}

And the MSpec tests for it

public abstract class specification_for_generate_workflows : Specification<GenerateAuthorisationWorkflows>
{
    protected static IWorkflowService workflowService;

    Establish context = () => { workflowService = DependencyOf<IWorkflowService>(); };
}

[Subject(typeof(GenerateAuthorisationWorkflows))]
public class when_generate_workflows_is_called_with_a_dta_object_list_and_an_employee : specification_for_generate_workflows
{
    static IList<Guid> result;
    static IList<DtaObject> dtaObjects;
    static Employee requestingEmployee;

    Establish context = () =>
    {
         var mocks = new MockRepository();
         var stubDtaObject1 = mocks.Stub<DtaObject>();
         var stubDtaObject2 = mocks.Stub<DtaObject>();
         var dtaObjectEnum = new List<DtaObject>{stubDtaObject1,stubDtaObject2}.GetEnumerator();
         dtaObjects = mocks.Stub<IList<DtaObject>>();
         dtaObjects.Stub(x => x.GetEnumerator()).Return(dtaObjectEnum).WhenCalled(x => x.ReturnValue = dtaObjectEnum);
         requestingEmployee = mocks.Stub<Employee>();
         mocks.ReplayAll();
    };

    Because of = () => result = subject.FromDtaObjects(dtaObjects, requestingEmployee);

    It should_enumerate_the_dta_objects = () => dtaObjects.received(x=> x.GetEnumerator());
    It should_call_workflow_host_helper = () => workflowService.AssertWasCalled(x => x.StartWorkflow());
}

With this configuration, my first test passes and my second test fails, as expected. I added a constructor to the class to inject the IWorkflowService.

public class GenerateAuthorisationWorkflows : IGenerateAuthorisationWorkflows
{
    IWorkflowService _workflowService;

    GenerateAuthorisationWorkflows(IWorkflowService workflowService)
    {
        _workflowService = workflowService;
    }

    public IList<Guid> FromDtaObjects(IList<DtaObject> dtaObjects, Employee requestingEmployee)
    {
        foreach (var dtaObject in dtaObjects)
        {
            Guid workflowKey = _workflowService.StartWorkflow();
        }

        return new List<Guid>();
    }

    public IList<Guid> FromDtaObjects()
    {
        return new List<Guid>();
    }
}

Now, when I run the tests, they fail at the Because:

System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.First(IEnumerable`1 source)
at MSpecTests.EmployeeRequestSystem.Tasks.Workflows.when_generate_workflows_is_called_with_a_dta_object_list_and_an_employee.<.ctor>b__4() in GenerateAuthorisationWorkflowsSpecs.cs: line 76 

For clarity, line 76 above is:

Because of = () => result = subject.FromDtaObjects(dtaObjects, requestingEmployee);

I’ve tried tracing the problem but am having no luck. I have tried setting up a constructor that takes no arguments but it raises the same error. I have similar classes with IoC dependencies that work fine using MSpec/Rhino Mocks, where am I going wrong?

  • 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-11T13:42:06+00:00Added an answer on June 11, 2026 at 1:42 pm

    Castle Windsor requires a public constructor to instantiate a class. Adding public to the constructor allows correct operation.

    public class GenerateAuthorisationWorkflows : IGenerateAuthorisationWorkflows
    {
        IWorkflowService _workflowService;
    
        public GenerateAuthorisationWorkflows(IWorkflowService workflowService)
        {
            _workflowService = workflowService;
        }
    
        public IList<Guid> FromDtaObjects(IList<DtaObject> dtaObjects, Employee requestingEmployee)
        {
            foreach (var dtaObject in dtaObjects)
            {
                Guid workflowKey = _workflowService.StartWorkflow();
            }
    
            return new List<Guid>();
        }
    
        public IList<Guid> FromDtaObjects()
        {
            return new List<Guid>();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have like 400 records on my database, suppose this is the first version
Using Dozer to map two objects, I have: /** /* This first class uses
I have this class file call SMSHelper.cs First I just wanted to know is
I have this middleware which is the first: class RedirectIt require net/https require uri
I have this view (DetailsContainer, first class in code section of this question) with
I am using the latest version of boost and boost.asio. I have this class:
I have this class [Serializable] public class myClass() : ISerializable { public int a;
I have this issue: first, I execute a SQL query using Java and then
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
i have two arrays like this first array Array ( [0228] => Array (

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.