public void GetProfile() { var expectedUser = new PriUser { Id = 2733, Name = "jack", FullName = "Jack Tsai", Department = "department", Degree = 1, Email = "my email", Homepage = "homepage", ExtNo = "12345", BackyardId = "jacktsai", }; this._userDao .Stub(o => o.GetOne(Arg<string>.Is.Anything)) .Return(expectedUser); var expectedSubCat = new CatSub { Id = 999, }; this._subCatDao .Stub(o => o.GetMany(Arg<int>.Is.Anything)) .Return(new[] { expectedSubCat }); var actual = this._target.GetProfile("jacktsai"); Assert.IsNotNull(actual); Assert.IsNotNull(actual.User); Assert.AreSame(expectedUser, actual.User); Assert.IsNotNull(actual.SubCatIds); Assert.AreEqual(1, actual.SubCatIds.Count()); Assert.AreEqual(999, actual.SubCatIds.ElementAt(0)); }
public void GetCategories() { var subCat1 = new CatSub { Id = 1, User = new CatSubUsr { UsrName = "pm name", }, MdyPm = "manager name", MdyPurher = string.Empty, MdyStaff = null, }; var subCat2 = new CatSub { Id = 3, User = new CatSubUsr(), MdyPm = string.Empty, MdyPurher = "purchaser name", MdyStaff = "staff name", }; this._subCatDao .Stub(o => o.GetMany(Arg<IEnumerable<int>>.Is.Anything)) .Return(new[] { subCat1, subCat2 }); var pm = new PriUser { Name = "pm name", }; var manager = new PriUser { Name = "manager name", }; var purchaser = new PriUser { Name = "purchaser name", }; var staff = new PriUser { Name = "staff name", }; this._userDao .Stub(o => o.GetMany(Arg<IEnumerable<string>>.Is.Anything)) .Return(new[] { pm, manager, purchaser, staff }); var subCats = this._target.GetCategoryContacts(new[] { 1, 2, 3 }); Assert.IsNotNull(subCats); Assert.AreEqual(2, subCats.Count()); var contact1 = subCats.ElementAt(0); Assert.AreEqual(1, contact1.Id); Assert.IsNotNull(contact1.Pm); Assert.AreEqual(pm.Name, contact1.Pm.Name); Assert.IsNotNull(contact1.Manager); Assert.AreEqual(manager.Name, contact1.Manager.Name); Assert.IsNull(contact1.Purchaser); Assert.IsNull(contact1.Staff); var contact2 = subCats.ElementAt(1); Assert.AreEqual(3, contact2.Id); Assert.IsNull(contact2.Pm); Assert.IsNull(contact2.Manager); Assert.IsNotNull(contact2.Purchaser); Assert.AreEqual(purchaser.Name, contact2.Purchaser.Name); Assert.IsNotNull(contact2.Staff); Assert.AreEqual(staff.Name, contact2.Staff.Name); }