public WhenDocumentsAreCreatedWithClassNameAsThePartitionKey()
        {
            //Given
            var collectionName = nameof(WhenDocumentsAreCreatedWithClassNameAsThePartitionKey);

            var docDbCollectionSettings = DocDbCollectionSettings.Create(collectionName, DocDbCollectionSettings.PartitionKeyTypeEnum.ClassName);

            this.testHarness = TestHarnessFunctions.GetDocumentDbTestHarness(collectionName, docDbCollectionSettings);

            //When
            for (var i = 0; i < 5; i++)
            {
                var car = new Car
                {
                    id   = Guid.NewGuid(),
                    Make = "Saab"
                };

                this.testHarness.DataStore.Create(car).Wait();
            }
            this.testHarness.DataStore.CommitChanges().Wait();

            //HACK: runtime manual override
            docDbCollectionSettings.EnableCrossParitionQueries = false;
        }
Example #2
0
 /// <summary>
 /// Initializes dispatcher-stack attaching method container work item.
 /// </summary>
 /// <param name="testHarness">Test harness.</param>
 /// <param name="instance">Test instance.</param>
 /// <param name="method">Method reflection object.</param>
 /// <param name="testMethod">Test method metadata.</param>
 /// <param name="granularity">Granularity of test.</param>
 public UnitTestMethodContainer(ITestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity)
     : base(instance, method, testMethod)
 {
     _granularity = granularity;
     _harness     = testHarness as UnitTestHarness;
     _testMethod  = testMethod;
 }
Example #3
0
        public WhenCallingRead()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingRead));

            var activeCarId       = Guid.NewGuid();
            var activeExistingCar = new Car
            {
                id   = activeCarId,
                Make = "Volvo"
            };

            var inactiveCarId       = Guid.NewGuid();
            var inactiveExistingCar = new Car
            {
                id     = inactiveCarId,
                Active = false,
                Make   = "Volvo"
            };

            this.testHarness.AddToDatabase(activeExistingCar);
            this.testHarness.AddToDatabase(inactiveExistingCar);

            // When
            this.carsFromDatabase = this.testHarness.DataStore.Read <Car>(car => car.Make == "Volvo").Result;
        }
Example #4
0
        public WhenCallingUpdateGiven1Of2ItemsExists()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateGiven1Of2ItemsExists));

            var volvoId = Guid.NewGuid();

            this.testHarness.AddToDatabase(
                new Car
            {
                id   = volvoId,
                Make = "Volvo"
            });

            var fordId = Guid.NewGuid();

            this.testHarness.AddToDatabase(
                new Car
            {
                id   = fordId,
                Make = "Ford"
            });

            //When
            this.result = this.testHarness.DataStore.UpdateWhere <Car>(c => c.Make == "Volvo", car => { }).Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
        public WhenCallingReadActiveByIdOnAnActiveItem()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingReadActiveByIdOnAnActiveItem));

            this.activeCarId = Guid.NewGuid();
            var activeExistingCar = new Car
            {
                id     = this.activeCarId,
                Active = true,
                Make   = "Volvo"
            };

            var inactiveCarId       = Guid.NewGuid();
            var inactiveExistingCar = new Car
            {
                id     = inactiveCarId,
                Active = false,
                Make   = "Jeep"
            };

            this.testHarness.AddToDatabase(activeExistingCar);
            this.testHarness.AddToDatabase(inactiveExistingCar);

            // When
            this.activeCarFromDatabase = this.testHarness.DataStore.ReadActiveById <Car>(this.activeCarId).Result;
        }
Example #6
0
        /// <summary>
        /// Instanciates the given harness and makes it accessible.
        /// Throws exceptions, if
        ///  ...type is not found
        ///  ... type is not a harness
        ///  ... assembly hosting the harness is not found.
        /// </summary>
        /// <param name="usedHarness"></param>
        /// <param name="assemblyName"></param>
        public static void BeginTestCase(string usedHarness, string assemblyName)
        {
            Type harness;

            logger.Info("Load harness " + usedHarness + " from " + assemblyName);
            if (!string.IsNullOrWhiteSpace(assemblyName))
            {
                var assembly = System.Reflection.Assembly.LoadFrom(assemblyName);
                harness = assembly.GetType(usedHarness);
            }
            else
            {
                // Find implementing testharness
                harness = Type.GetType(usedHarness, null, null, true);
            }

            var implementsTestharness = harness.GetInterface("ITestHarness") != null;

            if (!implementsTestharness)
            {
                var ex = new InvalidCastException("The type " + usedHarness + " is not a testharness.");
                logger.ErrorException("Not a harness!", ex);
                throw ex;
            }

            // Instanciate Testharness, ready to go :)
            theHarness   = harness.GetConstructor(new Type[0]).Invoke(new object[0]) as ITestHarness;
            testContext  = IOC.Resolve <ITestContext>();
            testCaseCode = null;
            testResults  = new List <TestResult>();
        }
        public WhenCallingReadActiveByIdOnAnItemAddedInTheCurrentSession()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingReadActiveByIdOnAnItemAddedInTheCurrentSession));

            var carId       = Guid.NewGuid();
            var existingCar = new Car
            {
                id     = carId,
                Active = true,
                Make   = "Volvo"
            };

            this.testHarness.AddToDatabase(existingCar);

            var newCarId = Guid.NewGuid();

            this.testHarness.DataStore.Create(
                new Car
            {
                id     = newCarId,
                Active = true,
                Make   = "Ford"
            }).Wait();

            this.newCarFromSession = this.testHarness.DataStore.ReadActiveById <Car>(newCarId).Result;
        }
Example #8
0
        public WhenChangingTheItemPassedIntoUpdate()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenChangingTheItemPassedIntoUpdate));

            this.carId = Guid.NewGuid();
            var existingCar = new Car
            {
                id   = this.carId,
                Make = "Volvo"
            };

            this.testHarness.AddToDatabase(existingCar);

            //read from db to pickup changes to properties made by datastore oncreate
            var existingCarFromDb = this.testHarness.DataStore.ReadActiveById <Car>(this.carId).Result;

            existingCarFromDb.Make = "Ford";

            this.testHarness.DataStore.Update(existingCarFromDb).Wait();

            //change the id before committing, if not cloned this would cause the item not to be found
            existingCarFromDb.id = Guid.NewGuid();

            //When
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #9
0
 /// <summary>
 /// Initializes dispatcher-stack attaching method container work item.
 /// </summary>
 /// <param name="testHarness">Test harness.</param>
 /// <param name="instance">Test instance.</param>
 /// <param name="method">Method reflection object.</param>
 /// <param name="testMethod">Test method metadata.</param>
 /// <param name="granularity">Granularity of test.</param>
 public UnitTestMethodContainer(ITestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity)
     : base(instance, method, testMethod)
 {
     _granularity = granularity;
     _harness = testHarness as UnitTestHarness;
     _testMethod = testMethod;
 }
Example #10
0
 /// <summary>
 /// Creates a new unit test assembly wrapper.
 /// </summary>
 /// <param name="provider">Unit test metadata provider.</param>
 /// <param name="unitTestHarness">A reference to the unit test harness.</param>
 /// <param name="assembly">Assembly reflection object.</param>
 public UnitTestFrameworkAssembly(IUnitTestProvider provider, ITestHarness unitTestHarness, Assembly assembly)
 {
     _provider = provider;
     _harness = unitTestHarness;
     _assembly = assembly;
     _init = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyInitialize);
     _cleanup = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyCleanup);
 }
Example #11
0
 /// <summary>
 /// Creates a new unit test assembly wrapper.
 /// </summary>
 /// <param name="provider">Unit test metadata provider.</param>
 /// <param name="unitTestHarness">A reference to the unit test harness.</param>
 /// <param name="assembly">Assembly reflection object.</param>
 public UnitTestFrameworkAssembly(IUnitTestProvider provider, ITestHarness unitTestHarness, Assembly assembly)
 {
     _provider = provider;
     _harness  = unitTestHarness;
     _assembly = assembly;
     _init     = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyInitialize);
     _cleanup  = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyCleanup);
 }
 public MainWindow(ITestHarness th)
 {
     th_ = th;
     //comm.sndr.CreateSendChannel(endPoint);
     comm.rcvr.CreateRecvChannel(endPoint);
     rcvThread_THtoCl = comm.rcvr.start(rcvThreadProc_THtoCl);
     //rcvThread_RepotoCl= comm.rcvr.start(rcvThreadProc_RepotoCl);
 }
        public WhenCallingUpdateGivenTheItemDoesNotExist()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateGivenTheItemDoesNotExist));

            //When
            this.result = this.testHarness.DataStore.Update(new Car()).Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #14
0
        public static void Init()
        {
            te           = IOC.Resolve <ITestEnvironment>();
            testContext  = IOC.Resolve <ITestContext>();
            testCaseCode = null;
            theHarness   = null;

            logger.Info("MutaGen Api - Init");
        }
Example #15
0
        public WhenCallingUpdateWhereGivenNoItemsExist()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateWhereGivenNoItemsExist));

            //When
            this.result = this.testHarness.DataStore.UpdateWhere <Car>(c => c.Make == "DoesNotExist", car => { }).Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #16
0
 public Client(ITestHarness th)
 {
     Console.Write("\n  Creating instance of Client");
     th_ = th;
     //comm.sndr.CreateSendChannel(endPoint);
     comm.rcvr.CreateRecvChannel(endPoint);
     rcvThread_THtoCl = comm.rcvr.start(rcvThreadProc_THtoCl);
     //rcvThread_RepotoCl= comm.rcvr.start(rcvThreadProc_RepotoCl);
 }
 public void TearDown()
 {
   if (harness != null)
   {
     harness.Dispose();
     harness = null;
     framework = null;
     sampleAssembly = null;
   }
 }
    public void SetUp()
    {
      sampleAssembly = GetSampleAssembly();

      harness = new DefaultTestHarness(TestContextTrackerAccessor.GetInstance(),
        RuntimeAccessor.Instance.Resolve<ILoader>());

      framework = CreateFramework();
      harness.AddTestFramework(framework);
    }
        public WhenCallingUpdateByIdGivenTheItemDoesNotExist()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateByIdGivenTheItemDoesNotExist));

            var carId = Guid.NewGuid();

            //When
            this.result = this.testHarness.DataStore.UpdateById <Car>(carId, car => car.Make = "Whatever").Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
        public WhenCallingCreateWithoutCommitting()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingCreateWithoutCommitting));

            var newCar = new Car
            {
                id   = Guid.NewGuid(),
                Make = "Volvo"
            };

            //When
            this.result = this.testHarness.DataStore.Create(newCar).Result;
        }
Example #21
0
        /// <summary>
        /// Initialize a new writer class.
        /// </summary>
        /// <param name="harness">The test harness instance.</param>
        /// <param name="messageFactory">
        /// The factory to use when creating new messages.
        /// </param>
        public LogMessageWriter(ITestHarness harness, LogMessageFactory messageFactory)
        {
            if (harness == null)
            {
                throw new ArgumentNullException("harness");
            }
            else if (messageFactory == null)
            {
                throw new ArgumentNullException("messageFactory");
            }

            _testHarness = harness;
            _factory     = messageFactory;
        }
Example #22
0
        public WhenCallingUpdateOnAnItemThatNoLongerExistsInTheDatabase()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateOnAnItemThatNoLongerExistsInTheDatabase));

            var deletedCar = new Car
            {
                id   = Guid.NewGuid(),
                Make = "Volvo"
            };

            //When
            this.result = this.testHarness.DataStore.Update(deletedCar).Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #23
0
        public WhenCallingCreateWithTheReadOnlyFlagSetToTrue()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingCreateWithTheReadOnlyFlagSetToTrue));

            this.newCarId = Guid.NewGuid();
            var newCar = new Car
            {
                id   = this.newCarId,
                Make = "Volvo"
            };

            //When
            this.testHarness.DataStore.Create(newCar, true).Wait();
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #24
0
        public WhenCallingUpdateWhereWithoutCommitting()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateWhereWithoutCommitting));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });

            //When
            this.testHarness.DataStore.UpdateWhere <Car>(car => car.id == this.carId, car => car.Make = "Ford").Wait();
        }
        public WhenCallingDeleteHardWhereWithoutCommitting()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingDeleteHardWhereWithoutCommitting));

            var carId = Guid.NewGuid();

            this.testHarness.AddToDatabase(
                new Car
            {
                id   = carId,
                Make = "Volvo"
            });

            //When
            this.testHarness.DataStore.DeleteHardWhere <Car>(car => car.id == carId).Wait();
        }
        public WhenCallingDeleteSoftWhere()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingDeleteSoftWhere));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });

            //When
            this.testHarness.DataStore.DeleteSoftWhere <Car>(car => car.id == this.carId).Wait();
            this.testHarness.DataStore.CommitChanges().Wait();
        }
        public WhenCallingUpdateWhereOnAnItemDeletedInThisSession()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateWhereOnAnItemDeletedInThisSession));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });
            this.testHarness.DataStore.DeleteHardById <Car>(this.carId).Wait();

            //When
            this.results = this.testHarness.DataStore.UpdateWhere <Car>(car => car.id == this.carId, car => car.Make = "Ford").Result;
        }
Example #28
0
        public WhenCallingUpdateById()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateById));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });

            //When
            this.testHarness.DataStore.UpdateById <Car>(this.carId, car => car.Make = "Ford").Wait();
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #29
0
        public WhenCallingExistsOnAnItemThatHasBeenDeletedInTheCurrentSession()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingExistsOnAnItemThatHasBeenDeletedInTheCurrentSession));

            this.activeCarId = Guid.NewGuid();
            var activeExistingCar = new Car
            {
                id   = this.activeCarId,
                Make = "Volvo"
            };

            this.testHarness.AddToDatabase(activeExistingCar);

            // When
            this.testHarness.DataStore.DeleteHardById <Car>(this.activeCarId).Wait();
        }
Example #30
0
        public WhenCallingDeleteHardById()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingDeleteHardById));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });

            //When
            this.result = this.testHarness.DataStore.DeleteHardById <Car>(this.carId).Result;
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #31
0
        public WhenCallingCommitMultipleTimesAfterACreateOperation()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingCommitMultipleTimesAfterACreateOperation));

            this.newCarId = Guid.NewGuid();
            var newCar = new Car
            {
                id   = this.newCarId,
                Make = "Volvo"
            };

            this.car = this.testHarness.DataStore.Create(newCar).Result;

            //When
            this.testHarness.DataStore.CommitChanges().Wait();
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #32
0
        public WhenCallingReadCommittedWithATransformationToTheSameType()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingReadCommittedWithATransformationToTheSameType));

            var carId       = Guid.NewGuid();
            var existingCar = new Car
            {
                id     = carId,
                Active = false,
                Make   = "Volvo"
            };

            this.testHarness.AddToDatabase(existingCar);

            // When
            this.carFromDatabase = this.testHarness.DataStore.Advanced.ReadCommitted((IQueryable <Car> cars) => cars.Where(car => car.id == carId)).Result.Single();
        }
        public WhenChangingTheItemsReturnedFromDeleteSoftDeleteWhere()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenChangingTheItemsReturnedFromDeleteSoftDeleteWhere));

            this.carId = Guid.NewGuid();
            this.testHarness.AddToDatabase(
                new Car
            {
                id   = this.carId,
                Make = "Volvo"
            });

            var result = this.testHarness.DataStore.DeleteSoftWhere <Car>(car => car.id == this.carId).Result;

            //When
            result.Single().id = Guid.NewGuid(); //change in memory before commit
            this.testHarness.DataStore.CommitChanges().Wait();
        }
        public WhenCallingUpdateTwiceInOneSession()
        {
            // Given
            this.testHarness = TestHarnessFunctions.GetTestHarness(nameof(WhenCallingUpdateTwiceInOneSession));

            this.carId = Guid.NewGuid();
            var existingCar = new Car
            {
                id   = this.carId,
                Make = "Volvo"
            };

            this.testHarness.AddToDatabase(existingCar);

            //When
            this.testHarness.DataStore.UpdateById <Car>(this.carId, c => c.Make = "Toyota").Wait();
            this.testHarness.DataStore.UpdateById <Car>(this.carId, c => c.Make = "Honda").Wait();
            this.testHarness.DataStore.CommitChanges().Wait();
        }
Example #35
0
        public void Run(UnitTestSettings settings)
        {
            // Avoid having the Run method called twice
            if (_harness != null)
            {
                return;
            }

            // Track the most recent system in use
            _system = this;

            _harness = settings.TestHarness;
            if (_harness == null)
            {
                throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestSystem_Run_NoTestHarnessInSettings);
            }
            _harness.Initialize(settings);
            _harness.TestHarnessCompleted += (sender, args) => OnTestHarnessCompleted(args);
            _harness.Run();
        }
Example #36
0
 /// <summary>
 /// Initializes the unit test log message writer helper.
 /// </summary>
 /// <param name="harness">The test harness reference.</param>
 public UnitTestLogMessageWriter(ITestHarness harness) : base(harness) 
 { 
 }