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

  • Home
  • SEARCH
  • 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 3942502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:40:15+00:00 2026-05-20T00:40:15+00:00

My web app uses half a dozen tables, each of which get populated when

  • 0

My web app uses half a dozen tables, each of which get populated when a user passes through the system. In order to do stats analysis I’ve written a database view to flatten these tables into a single view.

The view is working, however, I want to automate some tests around the view creation.

My idea to do this was to create a model/map and repository for the view – with list action only. My current implementation doesn’t work.

This is my Repository:

namespace FunctionalTests.SpssView
{
    public class SpssRepository
    {
        private readonly ISessionManager _sessionManager;

        public SpssRepository(ISessionManager sessionManager)
        {
            _sessionManager = sessionManager;
        }

        public IList<Spss> ListFromSpssView()
        {
            ICriteria criteria = _sessionManager.GetSession().CreateCriteria(typeof(Spss));
            return criteria.List<Spss>();
        }
    }
}

This is the model class:

namespace FunctionalTests.SpssView
{
    public class Spss
    {
        public virtual String StudentId { get; set; }
        public virtual String UPNSCN { get; set; }
        ...
    }
}

And the mapping:

namespace FunctionalTests.SpssView
{
    public sealed class SpssMap : ClassMap<Spss>
    {
        public SpssMap()
        {
            Id(x => x.StudentId).GeneratedBy.Assigned();
            Map(x => x.UPNSCN);
            ...
        }
    }
}

I’m not entirely confident in the ID mapping – as it is just read from the view?

This is my test:

    [Test]
    public void ShouldPopulateAndRetrieveFromSpssView()
    {   
        var mockSessionManager = new Mock<ISessionManager>();
        mockSessionManager.Setup(x => x.GetSession()).Returns(_session);

        var caseRepository = new CaseRepository(mockSessionManager.Object);
        var caseList = caseRepository.ListCases();
        Assert.That(caseList.Count, Is.EqualTo(2));

        var repository = new SpssRepository(mockSessionManager.Object);

        var spssList = repository.ListFromSpssView();

        Assert.That(spssList.Count, Is.EqualTo(2));
    }   

Note the case list code – I put that in there to make sure the db connection was being made. This part of the test passes.

Running select * from spss; returns two results. (I’m using sql server 2005 fwiw)

And because this isn’t production code, I created a new folder in my FunctionalTests visual studio project (I mention this, because it seems to me to be one of the main differences between this and my working repositories.) Should this make a difference??

Is it possible to test views like this?
Is there anyway I can see the sql that is being generated?
What am I doing wrong??!?

Thanks 🙂

  • 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-05-20T00:40:16+00:00Added an answer on May 20, 2026 at 12:40 am

    Try adding:

        public SpssMap()
        {
           Table("myViewBame"); // ADD THIS
            Id(x => x.StudentId).GeneratedBy.Assigned();
            Map(x => x.UPNSCN);
            ...
        }
    

    In order to see the generated SQL add this:

    .ShowSql()
    

    For example:

    Fluently.Configure().Database(
                            MsSqlConfiguration.MsSql2005
                                .ConnectionString(
                                    ConfigurationManager.ConnectionStrings["my"].ConnectionString).ShowSql())
                            .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyClass>())
                            .BuildSessionFactory();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight web app which uses ASP.net Website administration tool for user
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I am putting together a fairly simple web app that uses user inputted data
I have a web app which uses Devise for authentication. It is a site
I have a web app which uses Devise for authentication. It is a site
Our .NET web app uses ODP.NET for connections and its Oracle User for connecting
I have an iPhone web app which uses a cache.manifest file to successfully cache
My asp.net web app uses a master page which contains an 8k jpg of
I am writing a web app which uses SQL as input. This SQL must
Our web app uses SystemPropertyPlaceholder to load property files depending on the value of

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.