protected override SaveThingyCommand Given() { _model = null; var cmd = Fixture.Create<SaveThingyCommand>(); return cmd; }
protected override SaveThingyCommand Given() { _model = Fixture.Create<ThingyCommandDto>(); _originalModelId = Guid.Empty; _model.Id = _originalModelId; var cmd = Fixture.Create<SaveThingyCommand>(); cmd.Context.CreateAndAddThingy().ReturnsForAnyArgs(Fixture.Create<Thingy>()); cmd.Context.SaveChanges().ReturnsForAnyArgs(1); return cmd; }
protected override SaveThingyCommand Given() { _model = Fixture.Create<ThingyCommandDto>(); _originalModelId = Guid.Empty; _model.Id = _originalModelId; var cmd = Fixture.Create<SaveThingyCommand>(); Context.When(call => call.SaveChangesAsync()).DoNotCallBase(); Context.SaveChangesAsync().ReturnsForAnyArgs(Task.Run(()=>1)); return cmd; }
protected override SaveThingyCommand Given() { _model = Fixture.Create<ThingyCommandDto>(); _originalModelId = Fixture.Create<Guid>(); _model.Id = _originalModelId; _existingEntity = Fixture.Create<Thingy>(); _existingEntity.Id = _originalModelId; var cmd = Fixture.Create<SaveThingyCommand>(); Context.Thingys.Add(_existingEntity); return cmd; }
protected override SaveThingyCommand Given() { _model = Fixture.Create<ThingyCommandDto>(); _originalModelId = Fixture.Create<Guid>(); _model.Id = _originalModelId; _existingEntity = Fixture.Create<Thingy>(); _existingEntity.Id = _originalModelId; var cmd = Fixture.Create<SaveThingyCommand>(); //IQueryable is not mocked well, so instead use a List var existingThingys = Fixture.Create<List<Thingy>>(); existingThingys.Add(_existingEntity); cmd.Context.Thingys = existingThingys.AsQueryable(); cmd.Context.SaveChanges().ReturnsForAnyArgs(0); return cmd; }