/// <summary> /// Update a thing header. /// </summary> /// <param name="pos">The position of the thing.</param> /// <param name="type">The type of update being done.</param> /// <param name="stackpos">The stackpos of the thing.</param> private void UpdateThingHeaders(Position pos, UpdateThing type, byte stackpos) { netmsg.AddU16(0x19); netmsg.AddPosition(pos); netmsg.AddByte((byte)type); //sub-header, 0 = remove, 1 = add, 2 = update netmsg.AddByte(stackpos); }
public void Thing_CRUD_Positive() { // create Place place = null; Thing thing = null; Func <Task> asyncFunction = async() => { place = await CreatePlace(Client); thing = await CreateThing(Client, place); }; asyncFunction.ShouldNotThrow(); thing.Should().NotBeNull(); // read asyncFunction = async() => thing = await Client.ReadThing(thing.Id); asyncFunction.ShouldNotThrow(); thing.Should().NotBeNull(); // read list IEnumerable <Thing> things = null; asyncFunction = async() => things = await Client.ReadThings(place.Id); asyncFunction.ShouldNotThrow(); things.Should().NotBeNullOrEmpty(); things.Any(x => x.Id == thing.Id).Should().BeTrue(); // update var update = new UpdateThing(thing) { Name = thing.Name + " Updated" }; asyncFunction = async() => thing = await Client.UpdateThing(thing.Id, update); asyncFunction.ShouldNotThrow(); thing.Should().NotBeNull(); thing.Name.Should().NotBeNull(update.Name); // delete asyncFunction = async() => await Client.DeleteThing(thing.Id); asyncFunction.ShouldNotThrow(); // read list asyncFunction = async() => things = await Client.ReadThings(place.Id); asyncFunction.ShouldNotThrow(); things.Should().BeNullOrEmpty(); // delete place asyncFunction = async() => await Client.DeletePlace(place.Id); asyncFunction.ShouldNotThrow(); }