public DomainObjectGrainTests() { A.CallTo(() => store.WithSnapshotsAndEventSourcing(typeof(MyDomainObject), id, A <Func <MyDomainState, Task> > .Ignored, A <Func <Envelope <IEvent>, Task> > .Ignored)) .Returns(persistence); sut = new MyDomainObject(store); }
public DomainObjectGrainTests() { A.CallTo(() => store.WithSnapshotsAndEventSourcing(typeof(MyDomainObject), id, A <HandleSnapshot <MyDomainState> > .Ignored, A <HandleEvent> .Ignored)) .Returns(persistence); sut = new MyDomainObject(store); }
public void TestThatRaisePropertyChangedCallEventHandler() { var fixture = new Fixture(); var sender = fixture.CreateAnonymous <object>(); var propertyName = fixture.CreateAnonymous <string>(); var domainObject = new MyDomainObject(); Assert.That(domainObject, Is.Not.Null); var eventHandlerCalled = false; domainObject.PropertyChanged += ((s, e) => { Assert.That(s, Is.Not.Null); Assert.That(s, Is.EqualTo(sender)); Assert.That(e, Is.Not.Null); Assert.That(e.PropertyName, Is.Not.Null); Assert.That(e.PropertyName, Is.Not.Empty); Assert.That(e.PropertyName, Is.EqualTo(propertyName)); eventHandlerCalled = true; }); domainObject.RaisePropertyChanged(sender, propertyName); Assert.That(eventHandlerCalled, Is.True); }
public ActionResult Index() { var domainObject = new MyDomainObject(); var task = new MyTask(); task.DoSomething(domainObject); return View(); }
public MainWindow() { InitializeComponent(); var domainObject = new MyDomainObject(); var task = new MyTask(); task.DoSomething(domainObject); }
public DefaultDomainObjectRepositoryTests() { domainObject = new MyDomainObject(aggregateId, 123); streamNameResolver.Setup(x => x.GetStreamName(It.IsAny <Type>(), aggregateId)).Returns(streamName); factory.Setup(x => x.CreateNew(typeof(MyDomainObject), aggregateId)).Returns(domainObject); sut = new DefaultDomainObjectRepository(factory.Object, eventStore.Object, streamNameResolver.Object, eventDataFormatter.Object); }
public void TestThatRaisePropertyChangedThrowsAnArgumentNullExceptionIfPropertyNameIsEmpty() { var fixture = new Fixture(); var domainObject = new MyDomainObject(); Assert.That(domainObject, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => domainObject.RaisePropertyChanged(fixture.CreateAnonymous <object>(), string.Empty)); }
public void TestThatRaisePropertyChangedThrowsAnArgumentNullExceptionIfSenderIsNull() { var fixture = new Fixture(); var domainObject = new MyDomainObject(); Assert.That(domainObject, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => domainObject.RaisePropertyChanged(null, fixture.CreateAnonymous <string>())); }
public LogSnapshotDomainObjectGrainTests() { A.CallTo(() => store.WithEventSourcing(typeof(MyDomainObject), id, A <HandleEvent> .Ignored)) .Returns(persistence); A.CallTo(() => store.GetSnapshotStore <MyDomainState>()) .Returns(snapshotStore); sut = new MyDomainObject(store); }
public DefaultDomainObjectRepositoryTests() { domainObject = new MyDomainObject(aggregateId, 123); A.CallTo(() => nameResolver.GetStreamName(A <Type> .Ignored, aggregateId)) .Returns(streamName); A.CallTo(() => factory.CreateNew <MyDomainObject>(aggregateId)) .Returns(domainObject); sut = new DefaultDomainObjectRepository(eventStore, nameResolver, formatter); }
public void TestThatRaisePropertyChangedReturnsIfEventHandlerNotSet() { var fixture = new Fixture(); var sender = fixture.CreateAnonymous <object>(); var propertyName = fixture.CreateAnonymous <string>(); var domainObject = new MyDomainObject(); Assert.That(domainObject, Is.Not.Null); domainObject.RaisePropertyChanged(sender, propertyName); }
public AggregateHandlerTests() { sut = new AggregateHandler(factory, repository); domainObject = new MyDomainObject(Guid.NewGuid(), 1) .RaiseNewEvent(event1) .RaiseNewEvent(event2); context = new CommandContext(new MyCommand { AggregateId = domainObject.Id }); }
public void TestGreaterThanRuleCrossField() { Engine engine = new Engine(); engine.For <MyDomainObject <int> >() .Setup(m => m.Value1) .MustBeGreaterThan(a => a.Value2); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(3, 4))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(3, 3))); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(3, 2))); TestingValidationReport v = new TestingValidationReport(engine); MyDomainObject <int> o = new MyDomainObject <int>(3, 4); v.Validate(o); v.AssertError(o, p1 => p1.Value1, RuleKinds.GreaterThanRule, 4); }
public async Task Create_with_task_should_create_domain_object_and_save() { MyDomainObject passedDomainObject = null; await sut.CreateAsync <MyDomainObject>(context, async x => { x.RaiseEvent(new MyEvent()); await Task.Yield(); passedDomainObject = x; }); Assert.Equal(domainObject, passedDomainObject); Assert.NotNull(context.Result <EntityCreatedResult <Guid> >()); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .Ignored)) .MustHaveHappened(); }
public async Task Update_synced_should_create_domain_object_and_save() { MyDomainObject passedDomainObject = null; await sut.UpdateSyncedAsync <MyDomainObject>(context, x => { x.RaiseEvent(new MyEvent()); x.RaiseEvent(new MyEvent()); passedDomainObject = x; }); Assert.Equal(2, domainObject.Snapshot.Version); Assert.Equal(domainObject, passedDomainObject); Assert.NotNull(context.Result <EntitySavedResult>()); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .Ignored)) .MustHaveHappened(); }
public void TestBetweenRuleCrossFieldLessAndGreater() { Engine engine = new Engine(); engine.For <MyDomainObject <int> >() .Setup(m => m.Value1) .MustBeBetween(a => a.Value2, a => a.Value3); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(3, 2, 5))); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(3, 3, 3))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(3, 4, 5))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(3, 1, 2))); TestingValidationReport v = new TestingValidationReport(engine); MyDomainObject <int> o = new MyDomainObject <int>(4, 1, 3); v.Validate(o); v.AssertError(o, p1 => p1.Value1, RuleKinds.BetweenRule, 1, 3, 4, BetweenRuleBoundsOption.BothInclusive); }
public void TestLessThanOrEqualToRuleCrossField() { var builder = new Fluent.FluentBuilder(); builder.For <MyDomainObject <int> >() .Setup(m => m.Value1) .MustBeLessThanOrEqualTo(a => a.Value2); var engine = builder.Build(); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(3, 4))); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(3, 3))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(3, 2))); TestingValidationReport v = new TestingValidationReport(engine); MyDomainObject <int> o = new MyDomainObject <int>(4, 3); v.Validate(o); v.AssertError(o, p1 => p1.Value1, RuleKinds.LessThanOrEqualToRule, 3); }
public void TestBetweenRuleCrossFieldLess() { Engine engine = new Engine(); engine.For <MyDomainObject <int> >() .Setup(m => m.Value1) .MustBeBetween(6, a => a.Value2); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(7, 10))); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(6, 6))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(5, 10))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(8, 7))); TestingValidationReport v = new TestingValidationReport(engine); MyDomainObject <int> o = new MyDomainObject <int>(4, 3); v.Validate(o); v.AssertError(o, p1 => p1.Value1, RuleKinds.BetweenRule, 6, 3, 4, BetweenRuleBoundsOption.BothInclusive); }
public void TestBetweenRuleCrossFieldGreater() { Engine engine = new Engine(); engine.For <MyDomainObject <int> >() .Setup(m => m.Value1) .MustBeBetween(a => a.Value2, 10); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(7, 5))); Assert.IsTrue(engine.Validate(new MyDomainObject <int>(6, 6))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(5, 6))); Assert.IsFalse(engine.Validate(new MyDomainObject <int>(11, 15))); TestingValidationReport v = new TestingValidationReport(engine); MyDomainObject <int> o = new MyDomainObject <int>(3, 4); engine.Validate(o, v, ValidationReportDepth.FieldShortCircuit); v.AssertError(o, p1 => p1.Value1, RuleKinds.BetweenRule, 4, 10, 3, BetweenRuleBoundsOption.BothInclusive); }
public async Task Create_sync_should_create_domain_object_and_save() { A.CallTo(() => factory.CreateNew <MyDomainObject>(domainObject.Id)) .Returns(domainObject); A.CallTo(() => repository.SaveAsync(domainObject, A <ICollection <Envelope <IEvent> > > .Ignored, A <Guid> .Ignored)) .Returns(TaskHelper.Done); MyDomainObject passedDomainObject = null; await sut.CreateAsync <MyDomainObject>(context, x => { passedDomainObject = x; }); Assert.Equal(domainObject, passedDomainObject); Assert.NotNull(context.Result <EntityCreatedResult <Guid> >()); A.CallTo(() => repository.SaveAsync(domainObject, A <ICollection <Envelope <IEvent> > > .Ignored, A <Guid> .Ignored)).MustHaveHappened(); }
public async Task Create_sync_should_create_domain_object_and_save() { factory.Setup(x => x.CreateNew(typeof(MyDomainObject), domainObject.Id)) .Returns(domainObject) .Verifiable(); repository.Setup(x => x.SaveAsync(domainObject, It.IsAny <ICollection <Envelope <IEvent> > >(), It.IsAny <Guid>())) .Returns(TaskHelper.Done) .Verifiable(); MyDomainObject passedDomainObject = null; await sut.CreateAsync <MyDomainObject>(context, x => { passedDomainObject = x; }); Assert.Equal(domainObject, passedDomainObject); Assert.NotNull(context.Result <EntityCreatedResult <Guid> >()); repository.VerifyAll(); }
public async Task Update_sync_should_create_domain_object_and_save() { repository.Setup(x => x.GetByIdAsync <MyDomainObject>(command.AggregateId, null)) .Returns(Task.FromResult(domainObject)) .Verifiable(); repository.Setup(x => x.SaveAsync(domainObject, It.IsAny <ICollection <Envelope <IEvent> > >(), It.IsAny <Guid>())) .Returns(TaskHelper.Done) .Verifiable(); MyDomainObject passedDomainObject = null; await sut.UpdateAsync <MyDomainObject>(context, x => { passedDomainObject = x; }); Assert.Equal(domainObject, passedDomainObject); Assert.NotNull(context.Result <EntitySavedResult>()); repository.VerifyAll(); }
public MyDomainObjectWcfAdapter(MyDomainObject obj) { this._object = obj; }
public DomainObjectTests() { sut = new MyDomainObject(store); }
public MyDomainObjectViewModel(MyDomainObject domainObject) { _domainObject = domainObject; }
public DomainObjectTests() { sut = new MyDomainObject(persistenceFactory); }
public void TestThatConstructorInitializeDomainObjectBase() { var domainObjectBase = new MyDomainObject(); Assert.That(domainObjectBase, Is.Not.Null); }