Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Alan Hemmings
@goblinfactory
here's a small spike project with a failing test
no build needed, just checkout the code and open the solution
the failing test , minimal code that gives the error, is in Tests/HelloOrigoSmokeTests.cs -> Happy_path()
should we take this offline? Or start a new discussion so that other folk can ask questions and not be drowned out by this thread?
Robert Friberg
@rofr
No, I think it's ok here
Alan Hemmings
@goblinfactory
updating the test, adding Config.Engines.CloseAll(); and try .. finally { Config.Engines.CloseAll(); still throws the exception.
Robert Friberg
@rofr
I recall an issue where the file system does not have time to sync
so lock is not released before next test commences
Alan Hemmings
@goblinfactory
the branch I gave you the link for and Happy_path is changed to run everything in 1 test only, so that removes that from the equation.
Busy re-creating the exact code from getting started, almost finished
Robert Friberg
@rofr
ok, got it. So looks like maybe the resharper shadow copy may be causing the problem them
then
Alan Hemmings
@goblinfactory
I'm not convinced.
this test throws System.IO.Exception cannot access the file
        [Test]
        public void Happy_path()
        {
            Config.Engines.CloseAll();

            try
            {
                Console.WriteLine("Hosting the engine");
                //------------------------------------
                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
                Environment.CurrentDirectory = path;
                var config = new EngineConfiguration()
                {
                    JournalPath = path
                };
                IEngine<VetModel> engine = Engine.For<VetModel>();


                Console.WriteLine("Executing commands");
                // ------------------------------------
                var cat = new Cat()
                {
                    DOB = DateTime.UtcNow,
                    Name = NameGenerator.Generate(Gender.Female)
                };
                engine.Execute(new RegisterBirthCommand(cat));


                Console.WriteLine("Executing query");
                // ------------------------------------
                var localEngine = (LocalEngineClient<VetModel>)engine;
                var cats = localEngine.Execute(db => db.Cats.Where(c => true)).ToArray();
                foreach (var c in cats) Console.WriteLine(c);
            }
            finally
            {
                Config.Engines.CloseAll();
            }
        }
i.e. I've gone overboard and set Environment.CurrentDirectory as well as JournalPath plus ensuring Engines.CloseAll before and after.
adding in thread.Sleeps does not fix either.
Robert Friberg
@rofr
So which line throws the exception?
Alan Hemmings
@goblinfactory
oops, code above ..config is not passed to Engine.For
Robert Friberg
@rofr
That's a classic mistake, it as happened more than just a few times :)
Alan Hemmings
@goblinfactory
Give me 10 minutes so that I can give you a solid failing test that's well written without being rushed, and will save us both much time and folks reading this (curiously) will not curse me for pasting bollocks code ;-D
quick question, what exact namespace, what exact 'serializable' attribute must be used?
I'm now getting class Foo (Cat) is not marked as serializable, and it is. mmm!
Robert Friberg
@rofr
That would be System.Serializable
Alan Hemmings
@goblinfactory
just checking I wasnt going crazy.
quickest way to give you the feedback is for you to clone this 'gist' / spike repo and run the test
clone that, and checkout branch fail2
the failing test is '\Tests\HelloOrigoSmokeTests.cs`
Alan Hemmings
@goblinfactory
ah gosh, I copied the walkthrough exactly, with just the 2 fixes required, and that works a treat, passing no problem!
Robert Friberg
@rofr
So the reason for the fail is that the query passed to Execute returns an IQueryable which is not serializable
Put the ToArray() inside the Execute instead and it will work
Alan Hemmings
@goblinfactory
<blush!>
Robert Friberg
@rofr
Nah, that's an easy mistake to make
Alan Hemmings
@goblinfactory
that fixes the serialisation, but still get the process cannot access the file, because it is being used by another process.
Alan Hemmings
@goblinfactory
Hi Robert, there's this one phrase I dont quite understand in the documentation, describing the RoyalFoodTaster, If a command fails, the taster is discarded and replaced with a clone of the real model, without requiring full restore. More importantly, the real model is readable while the taster is being rebuilt.
if the real model is still readable, (and valid) then why bother with rebuilding?
Robert Friberg
@rofr
The key here is that you have 2 identical models in memory.
If the royal food taster goes corrupt, you need to create a new one
Alan Hemmings
@goblinfactory
Ok got it; I had a performance test that appears superficially to contradict this; and my problem was that my test model was wastefully keeping a transaction history in memory that was never being queried. This resulted in a linear growth of model size in memory, resulting in a long clone times. (That's my theory) going to remove the transaction table from memory, ... that can always be recreated by replaying all the messages (wow.. that's incredible! ) ...and that should = a test that proves how it all works. If this works, I'd like to offer it for consideration as sample code for the docs?
so far, it looks like the sample code is thin on 'best practice' examples, or examples that show with tests, why (and when) you'd choose A over B.
Alan Hemmings
@goblinfactory
working on a small accounts demo.
Robert Friberg
@rofr
awesome, appreciate the love
Alan Hemmings
@goblinfactory
are there any open source projects or other samples that I can look at to glean some best practices; I'm quite in the dark and guessing, and writing very rudimentary tests, quite a slow process.
Robert Friberg
@rofr
Robert Friberg
@rofr
source is on github, link is on the about page
Alan Hemmings
@goblinfactory
ah...fantastic
Harry McIntyre
@mcintyre321
Is the blog engine.net provider around still? The post I googled is dead
Robert Friberg
@rofr
eww, we did not maintain that provider. To be honest we learned that blogengine.net is a can of worms we wish we had never opened :)