public void TestRemovePin() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); PersistenceContext context = this._provider.GetService <PersistenceContext>(); IUnitOfWork unit = this._provider.GetService <IUnitOfWork>(); var ian = userAccessor.FindUser("ian"); var ianPins = accessor.FindPins(ian); Assert.Equal(2, ianPins.Count); Assert.Equal(3, context.Pins.Count()); accessor.RemovePin(ianPins.First()); unit.Commit(); Assert.Equal(2, context.Pins.Count()); ianPins = accessor.FindPins(ian); Assert.Equal(1, ianPins.Count); Assert.Throws <ArgumentException>(() => { accessor.RemovePin(null); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.RemovePin(new Contracts.DTO.Pin()); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.RemovePin(new Contracts.DTO.Pin() { PinId = "NOTAREALPIN" }); unit.Commit(); }); }
public void TestFindPinsByUser() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); var ian = userAccessor.FindUser("ian"); var zach = userAccessor.FindUser("zach"); var kauf = accessor.FindPin("kauf"); var destinations = accessor.FindPin("dest"); var fuse = accessor.FindPin("fuse"); var ianPins = accessor.FindPins(ian); var zachPins = accessor.FindPins(zach); Assert.Equal(2, ianPins.Count); Assert.True(ianPins.Contains(kauf)); Assert.True(ianPins.Contains(fuse)); Assert.True(zachPins.Contains(destinations)); Assert.Throws <ArgumentException>(() => { accessor.FindPins(null); }); }
public void TestAddPin() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); PersistenceContext context = this._provider.GetService <PersistenceContext>(); IUnitOfWork unit = this._provider.GetService <IUnitOfWork>(); Assert.Equal(3, context.Pins.Count()); var zach = userAccessor.FindUser("zach"); accessor.AddPin(new Contracts.DTO.Pin() { BelongsTo = zach.UserId, Latitude = _lincoln.North, Longitude = _lincoln.East, Name = "Lincoln NE" }); unit.Commit(); Assert.Equal(4, context.Pins.Count()); var zachPins = accessor.FindPins(zach); Assert.Equal(2, zachPins.Count); Assert.Throws <ArgumentException>(() => { accessor.AddPin(null); }); Assert.Throws <ArgumentException>(() => { accessor.AddPin(new Contracts.DTO.Pin() { PinId = "kauf", BelongsTo = zach.UserId, Latitude = 0, Longitude = 0, Name = "Bad pin - duplicate" }); }); Assert.Throws <ArgumentException>(() => { accessor.AddPin(new Contracts.DTO.Pin() { Latitude = 0, Longitude = 0, Name = "Bad pin - no owner" }); }); Assert.Throws <ArgumentException>(() => { accessor.AddPin(new Contracts.DTO.Pin() { BelongsTo = zach.UserId, Name = "Bad pin - no coordinates" }); }); }
public void TestFindPinsByBox() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); var ian = userAccessor.FindUser("ian"); var zach = userAccessor.FindUser("zach"); var kauf = accessor.FindPin("kauf"); var destinations = accessor.FindPin("dest"); var fuse = accessor.FindPin("fuse"); Assert.Equal(1, accessor.FindPins(_campus, ian).Count); Assert.Equal(0, accessor.FindPins(_bottoms, ian).Count); Assert.Equal(2, accessor.FindPins(_lincoln, ian).Count); Assert.Equal(0, accessor.FindPins(_south, ian).Count); Assert.Equal(0, accessor.FindPins(_campus, zach).Count); Assert.Equal(1, accessor.FindPins(_bottoms, zach).Count); Assert.Equal(1, accessor.FindPins(_lincoln, zach).Count); Assert.Equal(0, accessor.FindPins(_south, zach).Count); var ianPins = accessor.FindPins(_lincoln, ian); Assert.True(ianPins.Contains(kauf)); Assert.True(ianPins.Contains(fuse)); Assert.Throws <ArgumentException>(() => { accessor.FindPins(null, ian); }); Assert.Throws <ArgumentException>(() => { accessor.FindPins(_campus, null); }); Assert.Throws <ArgumentException>(() => { accessor.FindPins(null, null); }); }