public void RemoveItem_CannotAlterFields_ReturnNull() { //arrange _config.AllowTransformToAlterFields = false; //it was set to true in test Initialize method IRecord rec = new KeyValRecord(_items, _recNo, 1, 0, null, null, null, _typeDefs, _config, null, ActionOnDuplicateKey.IgnoreItem); //act var result = rec.RemoveItem("D_date"); //assert result.Should().NotHaveValue(); Assert.IsNull(result); rec.Count.Should().Be(4); rec.RecNo.Should().Be(26); rec[0].Should().BeOfType(typeof(string)); rec[0].Should().Be("71941"); rec[3].Should().BeOfType(typeof(int)); rec[3].Should().Be(184); //act2 result = rec.RemoveItem("badKey"); //assert2 result.Should().NotHaveValue(); Assert.IsNull(result); rec.Count.Should().Be(4); rec.RecNo.Should().Be(26); rec[0].Should().BeOfType(typeof(string)); rec[0].Should().Be("71941"); rec[3].Should().BeOfType(typeof(int)); rec[3].Should().Be(184); }
public void RemoveItem_NonExistingKey_ReturnFalse() { //arrange IUntypedRecord rec = new KeyValRecord(_items, _recNo, 1, 0, null, null, null, _typeDefs, _config, null, ActionOnDuplicateKey.IgnoreItem); //act var result = rec.RemoveItem("badKey"); //assert result.Should().BeFalse(); rec.Count.Should().Be(4); rec.RecNo.Should().Be(26); rec[0].Should().BeOfType(typeof(string)); rec[0].Should().Be("71941"); rec[3].Should().BeOfType(typeof(string)); rec[3].Should().Be("184"); }
public void RemoveItem_ExistingKey_RemoveItemAndReturnTrue() { //arrange IUntypedRecord rec = new KeyValRecord(_items, _recNo, 1, 0, null, null, null, _typeDefs, _config, null, ActionOnDuplicateKey.IgnoreItem); //act var result = rec.RemoveItem("D_date"); //assert result.Should().BeTrue(); rec.Count.Should().Be(3); rec.RecNo.Should().Be(26); rec[0].Should().BeOfType(typeof(string)); rec[0].Should().Be("71941"); rec[1].Should().BeOfType(typeof(string)); rec[1].Should().Be("blahblah"); rec[2].Should().BeOfType(typeof(string)); rec[2].Should().Be("184"); }
public void RemoveItem_SimpleValues_CorrectData() { //arrange var items = new IItem[] { KeyValItem.CreateItem("IDCD_ID", "71941", _typeDefs), KeyValItem.CreateItem("blah", "blahblah", _typeDefs), KeyValItem.CreateItem("I_num", 243, _typeDefs) }; var rec = new KeyValRecord(items, 16, 1, 0, null, null, null, _typeDefs, _config, null, ActionOnDuplicateKey.IgnoreItem); IRecord recR = rec; IUntypedRecord recU = rec; dynamic recD = rec; //act rec.RemoveItem("nonExisting"); //should have no effect //assert rec.Count.Should().Be(3); rec.RecNo.Should().Be(16); rec.SourceNo.Should().Be(1); rec.Keys[0].Should().Be("IDCD_ID"); rec.GetItem("IDCD_ID").Key.Should().Be("IDCD_ID"); rec[1].Should().Be("blahblah"); rec["blah"].Should().Be("blahblah"); rec[2].Should().Be(243); rec["I_num"].Should().Be(243); //act2 rec.RemoveItem("blah"); //assert2 rec.Count.Should().Be(2); rec.RecNo.Should().Be(16); rec.SourceNo.Should().Be(1); rec.Keys[0].Should().Be("IDCD_ID"); rec.GetItem("IDCD_ID").Key.Should().Be("IDCD_ID"); recU[0].Should().Be("71941"); recR[0].Should().Be("71941"); Assert.AreEqual("71941", recD.IDCD_ID); rec[1].Should().Be(243); rec["I_num"].Should().Be(243); recU[1].Should().Be("243"); recR[1].Should().Be(243); Assert.AreEqual(243, recD.I_num); rec["blah"].Should().Be(null); rec[2].Should().Be(null); recU[2].Should().Be(null); recR[2].Should().Be(null); //act3 rec.RemoveItem("IDCD_ID"); //assert3 rec.Count.Should().Be(1); rec.RecNo.Should().Be(16); rec.SourceNo.Should().Be(1); rec.Keys[0].Should().Be("I_num"); rec.GetItem("I_num").Key.Should().Be("I_num"); rec[0].Should().Be(243); rec["I_num"].Should().Be(243); recU[0].Should().Be("243"); recR[0].Should().Be(243); Assert.AreEqual(243, recD.I_num); rec["IDCD_ID"].Should().Be(null); rec[1].Should().Be(null); recU[1].Should().Be(null); recR[1].Should().Be(null); }