public void GetScalar() { _persistenceStrategyMock.Expect(mock => mock.ExecuteScalarQuery(_scalarQuery)).Return(27); _persistenceStrategyMock.Replay(); var result = _queryManager.GetScalar(_scalarQuery); _persistenceStrategyMock.VerifyAllExpectations(); Assert.That(result, Is.EqualTo(27)); }
public void LoadObject() { _persistenceStrategyMock.Expect(mock => mock.LoadObjectData(DomainObjectIDs.Order1)).Return(_loadedObjectDataStub1); var throwOnNotFound = BooleanObjectMother.GetRandomBoolean(); _loadedObjectDataRegistrationAgentMock.Expect(mock => mock.RegisterIfRequired(Arg.Is(new[] { _loadedObjectDataStub1 }), Arg.Is(throwOnNotFound))); _mockRepository.ReplayAll(); var result = _objectLoader.LoadObject(DomainObjectIDs.Order1, throwOnNotFound); _mockRepository.VerifyAll(); Assert.That(result, Is.SameAs(_loadedObjectDataStub1)); }
public void NewObject() { var constructorParameters = ParamList.Create("Some Product"); _eventSinkWithMock.Expect(mock => mock.RaiseNewObjectCreatingEvent(_typeDefinitionWithCreatorMock.ClassType)); _persistenceStrategyMock.Expect(mock => mock.CreateNewObjectID(_typeDefinitionWithCreatorMock)).Return(_objectID1); _domainObjectCreatorMock .Expect( mock => mock.CreateNewObject(Arg <IObjectInitializationContext> .Is.Anything, Arg.Is(constructorParameters), Arg.Is(_transaction))) .WhenCalled(mi => CheckInitializationContext <NewObjectInitializationContext> (mi.Arguments[0], _objectID1, _transaction)) .Return(_domainObject1); var result = _agent.NewObject(_typeDefinitionWithCreatorMock, constructorParameters); _eventSinkWithMock.VerifyAllExpectations(); _persistenceStrategyMock.VerifyAllExpectations(); _domainObjectCreatorMock.VerifyAllExpectations(); Assert.That(result, Is.SameAs(_domainObject1)); }
private void ExpectPersistData(params PersistableData[] persistableDatas) { _persistenceStrategyMock.Expect(mock => mock.PersistData(Arg <IEnumerable <PersistableData> > .List.Equivalent(persistableDatas))); }