/// <summary> /// 制定包含使用byte[] 构造的对象实例 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entry"></param> /// <returns></returns> public bool RegisterDataEntry <T>(IDataEntry <T> entry) { if (!reflMap.ContainsKey(entry.DataType)) { reflMap.Add(entry.DataType, entry.GetType()); return(true); } return(false); }
public void PushEntry <T>(IDataEntry <T> entry) { if (!Pushing) { throw new InvalidOperationException("请先调用StarPush或者ContinuePush方法准备"); } stream.Write(getData((int)entry.DataType), 0, 4); stream.Write(getData(entry.DataSize), 0, 4); stream.Write(entry.data, 0, entry.data.Length); }
public void MethodAddUserShouldModifyTheFieldsOfTheClassItIsInAndThenPassItsOwnClassObjectAsAnArgumentToMethodInsertRowIntoTable() { // Arrange IDataEntry test = null; Mock <IUserTable> mockDatabase = new Mock <IUserTable>(); mockDatabase.Setup(r => r.TableName).Returns("Table Name"); mockDatabase.Setup(r => r.InsertRowIntoTable("Table Name", It.IsAny <IDataEntry>())).Callback <string, IDataEntry>((s1, s2) => { test = s2; }); IUserAdministration sut = new UserAdministration(user, mockDatabase.Object); // Act sut.AddUser("Bob", "*****@*****.**", "password", "password", "score"); // Assert Assert.AreSame(sut, test); Assert.AreEqual(sut, test); }
public void MethodAddTerritoryShouldModifyTheFieldsOfTheClassItIsInAndThenPassItsOwnClassObjectAsAnArgumentToMethodInsertRowIntoTable() { // Arrange IDataEntry test = null; Mock <ITerritoryTable> mockDatabase = new Mock <ITerritoryTable>(); mockDatabase.Setup(r => r.TableName).Returns("Table Name"); mockDatabase.Setup(r => r.InsertRowIntoTable("Table Name", It.IsAny <IDataEntry>())).Callback <string, IDataEntry>((s1, s2) => { test = s2; }); ITerritoryAdministration sut = new TerritoryAdministration(territory, mockDatabase.Object); // Act sut.AddTerritory("5F", "Billy-Bob", "Purple"); // Assert Assert.AreSame(sut, test); Assert.AreEqual(sut, test); }
public void AddingQuestion() { // Arrange IDataEntry test = null; Mock <IDataBaseTable> mockDatabase = new Mock <IDataBaseTable>(); Mock <IQuestion> mockQuestion = new Mock <IQuestion>(); mockQuestion.Setup(r => r.Question).Returns("Question 1"); mockQuestion.Setup(r => r.PointValue).Returns(4); mockDatabase.Setup(r => r.InsertRowIntoTable("Table Name", It.IsAny <IDataEntry>())).Callback <string, IDataEntry>((s1, s2) => { test = s2; }); IQuestionPack sut = new QuestionPack(mockQuestion.Object.QuestionPack, mockQuestion.Object.PointValue); // Act sut.AddQuestion("Question 1", "Answer 1", "Question Type"); // Assert Assert.AreSame(sut, test); Assert.AreEqual(sut, test); }
public void ConvertFrom(IDataEntry entry) { throw new InvalidCastException(); }
public DataEntryController(IDataEntry db) { _db = db; }