• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VolunteerService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VolunteerService的典型用法代码示例。如果您正苦于以下问题:C# VolunteerService类的具体用法?C# VolunteerService怎么用?C# VolunteerService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VolunteerService类属于命名空间,在下文中一共展示了VolunteerService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Register_ValidVolunteer

        public void Register_ValidVolunteer()
        {
            Person moqPerson = new Person()
            {
                Id = 1,
                UserId = null,
                FirstName = "Bob",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139",
                ClusterId = 1
            };

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.AddPerson(It.IsAny<Person>())).Returns(moqPerson);

            VolunteerService service = new VolunteerService(moqDataService.Object);
            Person actual = service.Register("Bob", "Jones", "[email protected]", "555-222-9139", 1, 5);

            Assert.AreEqual(1, actual.Id);
            Assert.AreEqual("Bob", actual.FirstName);
            Assert.AreEqual("Jones", actual.LastName);
            Assert.AreEqual("[email protected]", actual.Email);
            Assert.AreEqual("555-222-9139", actual.PhoneNumber);
            Assert.AreEqual(1, actual.ClusterId);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:26,代码来源:VolunteerServiceTest.cs


示例2: Register_UsernameAvailable

        public void Register_UsernameAvailable()
        {
            User moqUser = new User()
            {
                Id = 1,
                UserName = "test123"
            };

            List<User> users = new List<User>();
            users.Add(moqUser);

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.Users).Returns(users.AsQueryable());

            VolunteerService service = new VolunteerService(moqDataService.Object);

            //test that the username we created is not available.
            Assert.IsFalse(service.UsernameAvailable("test123"), "Username created for this test should report as not available.");

            //test that a different username is available.
            Assert.IsTrue(service.UsernameAvailable("test456"), "Username that was not added to our data source should report as available.");
        }
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:22,代码来源:VolunteerServiceTest.cs


示例3: GetPersonDetailsForChangeContactInfoReturnsExpectedData

        public void GetPersonDetailsForChangeContactInfoReturnsExpectedData()
        {
            var personOne = new Person
            {
                Id = 1,
                UserId = 6,
                FirstName = "Cathy",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139",
                ClusterId = 1
            };

            var personTwo = new Person
            {
                Id = 2,
                UserId = 7,
                FirstName = "Stan",
                LastName = "Smith",
                Email = "[email protected]",
                PhoneNumber = "111-333-2222"
            };

            var dataService = new Mock<IDataService>();
            var personList = new List<Person>
            {
                personOne,
                personTwo
            };
            dataService.Setup(x => x.Persons).Returns(personList.AsQueryable());
            var underTest = new VolunteerService(dataService.Object);

            var result = underTest.GetPersonDetailsForChangeContactInfo(personTwo.UserId.GetValueOrDefault());

            Assert.IsNotNull(result);
            Assert.AreEqual(personTwo.Email, result.Email);
            Assert.AreEqual(personTwo.PhoneNumber, result.PhoneNumber);
        }
开发者ID:vkarosas,项目名称:crisischeckin,代码行数:38,代码来源:VolunteerServiceTest.cs


示例4: Register_NullEmail

 public void Register_NullEmail()
 {
     VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
     service.Register("first", "last", "", "555-333-1111", 1, 3);
 }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:5,代码来源:VolunteerServiceTest.cs


示例5: WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException

        public void WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException()
        {
            var moqDataService = new Mock<IDataService>();
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };

            var results = underTest.RetrieveCommitmentsForDisaster(person, default(Disaster));
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:14,代码来源:VolunteerServiceTest.cs


示例6: WhenNoCommitmentsExistEmptyCollectionIsReturned

        public void WhenNoCommitmentsExistEmptyCollectionIsReturned()
        {
            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>().AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };
            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = true
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());

            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);
            Assert.IsTrue(results.Count() == 0);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:28,代码来源:VolunteerServiceTest.cs


示例7: UpdateDetails_Valid

        public void UpdateDetails_Valid()
        {
            Person moqPerson = new Person()
            {
                Id = 1,
                UserId = null,
                FirstName = "Cathy",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139",
                ClusterId = 1
            };

            List<Person> people = new List<Person>();
            people.Add(moqPerson);

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
            moqDataService.Setup(s => s.UpdatePerson(It.IsAny<Person>())).Returns(new Person() {
                Id = 1,
                Email = "[email protected]",
                FirstName = "Cathy",
                LastName = "CHANGED",
                PhoneNumber = "555-222-9139",
                ClusterId = 1
            });

            VolunteerService service = new VolunteerService(moqDataService.Object);
            var actual = service.UpdateDetails(new Person()
            {
                Id = 1, Email = "[email protected]", FirstName = "Cathy", LastName = "CHANGED", PhoneNumber = "555-222-9139", ClusterId = 1
            });

            // Only Last Name has been updated
            Assert.AreEqual("CHANGED", actual.LastName);

            Assert.AreEqual("Cathy", actual.FirstName);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:38,代码来源:VolunteerServiceTest.cs


示例8: Register_NullCluster

 public void Register_NullCluster()
 {
     VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
     service.Register("first", "last", "email", "555-333-1111", 0, 4);
 }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:5,代码来源:VolunteerServiceTest.cs


示例9: WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException

        public void WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException()
        {
            var moqDataService = new Mock<IDataService>();
            var underTest = new VolunteerService(moqDataService.Object);

            var results = underTest.RetrieveCommitments(default(Person), false);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:7,代码来源:VolunteerServiceTest.cs


示例10: Register_EmailAlreadyInUse_ReturnTrue

        public void Register_EmailAlreadyInUse_ReturnTrue()
        {
            Person moqPerson = new Person()
            {
                Id = 1,
                Email = "[email protected]"
            };

            List<Person> people = new List<Person>();
            people.Add(moqPerson);

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
            VolunteerService service = new VolunteerService(moqDataService.Object);
            Assert.IsTrue(service.EmailAlreadyInUse("[email protected]"));
        }		
开发者ID:dayewah,项目名称:crisischeckin,代码行数:16,代码来源:VolunteerServiceTest.cs


示例11: Register_NullLastName

 public void Register_NullLastName()
 {
     VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
     service.Register("first", "", "email", "555-333-1111", 1, 2);
 }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:5,代码来源:VolunteerServiceTest.cs


示例12: UpdateDetails_DoesNotClearFirstOrLastNameIfBlank

        public void UpdateDetails_DoesNotClearFirstOrLastNameIfBlank()
        {
            var moqPersonOne = new Person
            {
                Id = 1,
                UserId = 6,
                FirstName = "Cathy",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139"
            };

            var people = new List<Person> {moqPersonOne};

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
            moqDataService.Setup(s => s.UpdatePerson(It.IsAny<Person>())).Returns((Person p) => p);

            var service = new VolunteerService(moqDataService.Object);

            Person actual = service.UpdateDetails(new Person
            {
                Id = 1,
                UserId = 6,
                FirstName = null,
                LastName = null,
                Email = "[email protected]",
                PhoneNumber = "555-222-9139"
            });

            Assert.IsNotNull(actual);
            Assert.IsFalse(string.IsNullOrEmpty(actual.FirstName), "Expected First Name not to be null or empty.");
            Assert.IsFalse(string.IsNullOrEmpty(actual.LastName), "Expected Last Name not to be null or empty.");
        }
开发者ID:dayewah,项目名称:crisischeckin,代码行数:34,代码来源:VolunteerServiceTest.cs


示例13: WhenQueryingInactiveDisastersAllCommitmentsReturned

        public void WhenQueryingInactiveDisastersAllCommitmentsReturned()
        {
            var moqDataService = new Mock<IDataService>();
            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = false
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());

            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>
                {
                    new Commitment
                    {
                        DisasterId=1,
                        Id = 1,
                        PersonId=1,
                        StartDate=new DateTime(2013, 8, 1),
                        EndDate = new DateTime(2013, 9, 1),
                        Disaster=disaster
                    }
                }.AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            const int personId = 1;
            var results = underTest.RetrieveCommitments(personId, true);
            Assert.IsTrue(results.Count() == 1);
            Assert.IsTrue(results.Single().Id == 1);
        }
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:35,代码来源:VolunteerServiceTest.cs


示例14: WhenPersonIdDoesNotExistReturnsEmptyList

        public void WhenPersonIdDoesNotExistReturnsEmptyList()
        {
            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(service => service.Commitments).Returns(new List<Commitment>().AsQueryable);
            var underTest = new VolunteerService(moqDataService.Object);

            var results = underTest.RetrieveCommitments(0, false);
        }
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:8,代码来源:VolunteerServiceTest.cs


示例15: WhenNoCommitmentsExistAnywhereEmptyCollectionIsReturned

        public void WhenNoCommitmentsExistAnywhereEmptyCollectionIsReturned()
        {
            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>().AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = true
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());
            const int personId = 1;

            var results = underTest.RetrieveCommitments(personId, false);
            Assert.IsTrue(!results.Any());
        }
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:23,代码来源:VolunteerServiceTest.cs


示例16: UpdateDetails_ChangeEmailToUnusuedEmail_DoesNotThrowPersonEmailAlreadyInUseException

        public void UpdateDetails_ChangeEmailToUnusuedEmail_DoesNotThrowPersonEmailAlreadyInUseException()
        {
            Person moqPersonOne = new Person()
            {
                Id = 1,
                UserId = null,
                FirstName = "Cathy",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139"
            };

            List<Person> people = new List<Person>();
            people.Add(moqPersonOne);

            var moqDataService = new Mock<IDataService>();
            moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());

            VolunteerService service = new VolunteerService(moqDataService.Object);
            // Try to change Cathy Jones' email to something not in use...
            service.UpdateDetails(new Person()
            {
                Id = 1,
                Email = "[email protected]",
                FirstName = "Cathy",
                LastName = "Jones"
            });
        }
开发者ID:JaimeLynSchatz,项目名称:crisischeckin,代码行数:28,代码来源:VolunteerServiceTest.cs


示例17: GetPersonDetailsForChangeContactInfoThrowsExpectedPersonNotFoundException

        public void GetPersonDetailsForChangeContactInfoThrowsExpectedPersonNotFoundException()
        {
            var personOne = new Person
            {
                Id = 1,
                UserId = 6,
                FirstName = "Cathy",
                LastName = "Jones",
                Email = "[email protected]",
                PhoneNumber = "555-222-9139",
            };

            var personTwo = new Person
            {
                Id = 2,
                UserId = 7,
                FirstName = "Stan",
                LastName = "Smith",
                Email = "[email protected]",
                PhoneNumber = "111-333-2222"
            };

            var dataService = new Mock<IDataService>();
            var personList = new List<Person>
            {
                personOne,
                personTwo
            };
            dataService.Setup(x => x.Persons).Returns(personList.AsQueryable());
            var underTest = new VolunteerService(dataService.Object);

            var result = underTest.GetPersonDetailsForChangeContactInfo(8);
        }
开发者ID:dayewah,项目名称:crisischeckin,代码行数:33,代码来源:VolunteerServiceTest.cs


示例18: Register_NullPhoneNumber

 public void Register_NullPhoneNumber()
 {
     VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
     service.Register("first", "last", "email", "", 1, 3);
 }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:5,代码来源:VolunteerServiceTest.cs


示例19: UpdateDetails_NullPerson

        public void UpdateDetails_NullPerson()
        {
            var moqDataService = new Mock<IDataService>();
            VolunteerService service = new VolunteerService(moqDataService.Object);

            service.UpdateDetails(null);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:7,代码来源:VolunteerServiceTest.cs


示例20: WhenQueryingReturnCommitmentsOnlyForThisUser

        public void WhenQueryingReturnCommitmentsOnlyForThisUser()
        {
            var moqDataService = new Mock<IDataService>();
            var disaster = new Disaster
            {
                Id = 1,
                Name = "test",
                IsActive = true
            };
            moqDataService.Setup(ds => ds.Disasters)
                .Returns(new List<Disaster>
                {
                    disaster
                }.AsQueryable());

            moqDataService.Setup(ds => ds.Commitments)
                .Returns(new List<Commitment>
                {
                    new Commitment
                    {
                        DisasterId=1,
                        Id = 1,
                        PersonId=1,
                        StartDate=new DateTime(2013, 8, 1),
                        EndDate = new DateTime(2013, 9, 1),
                        Disaster=disaster
                    },
                    new Commitment
                    {
                        DisasterId=1,
                        Id = 2,
                        PersonId=2,
                        StartDate=new DateTime(2013, 8, 1),
                        EndDate = new DateTime(2013, 9, 1)
                    }
                }.AsQueryable());
            var underTest = new VolunteerService(moqDataService.Object);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "tester"
            };
            var results = underTest.RetrieveCommitmentsForDisaster(person, disaster);
            Assert.IsTrue(results.Count() == 1);
        }
开发者ID:jfazler,项目名称:crisischeckin,代码行数:47,代码来源:VolunteerServiceTest.cs



注:本文中的VolunteerService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VowpalWabbit类代码示例发布时间:2022-05-24
下一篇:
C# Volume类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap