Ejemplo n.º 1
0
        public async Task deleteSkillAsync(int skillId)
        {
            Skill skillFromRepository = await retrieveSkillAsync(skillId);

            if (skillFromRepository == null)
            {
                throw new NotFoundBusinessEntityException($"The skill {skillId} doesn't exist.");
            }

            FakeDataBase.getInstance().Skills.Remove(await retrieveSkillAsync(skillId));
        }
Ejemplo n.º 2
0
        public async Task deleteContactAsync(int id)
        {
            Contact contactToDelete = await retrieveContactAsync(id);

            if (contactToDelete == null)
            {
                throw new NotFoundBusinessEntityException($"The contact {id} doesn't exist.");
            }

            FakeDataBase.getInstance().Contacts.Remove(await retrieveContactAsync(id));
        }
Ejemplo n.º 3
0
        public void ValidateMemberTest驗證admin帳號密碼錯誤()
        {
            FakeDataBase fakeDataBase = new FakeDataBase();


            Service service = new Service(fakeDataBase);
            string  actual  = "";
            string  result  = "Password Error!";

            actual = service.ValidateMember("admin", "admin789");
            Assert.AreEqual(result, actual);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            FakeDataBase.InitData();
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IConsoleMenu, ConsoleMenu>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var menu            = serviceProvider.GetRequiredService <IConsoleMenu>();

            menu.Run();
        }
Ejemplo n.º 5
0
        public void ValidateMemberTest驗證admin帳號密碼正確()
        {
            FakeDataBase fakeDataBase = new FakeDataBase();
            //dt.Columns.Add("Account");
            //dt.Columns.Add("Password");
            //var newrow= dt.NewRow();
            //newrow["Account"] = "admin";
            //newrow["Password"] = "******";
            //dt.Rows.Add(newrow);


            Service service = new Service(fakeDataBase);
            string  actual  = "";
            string  result  = "Success!";

            actual = service.ValidateMember("admin", "admin123");
            Assert.AreEqual(result, actual);
        }
Ejemplo n.º 6
0
        public async Task <Skill> createSkillAsync(Skill skill)
        {
            Skill skillFromRepository = await retrieveSkillAsync(skill.Id);

            if (skillFromRepository != null)
            {
                throw new BusinnessDomainException($"The contact {skill.Id} already exists");
            }

            FakeDataBase.getInstance().Skills.Add(
                new Skill
            {
                Id    = skill.Id,
                Name  = skill.Name,
                Level = skill.Level
            }
                );

            return(await retrieveSkillAsync(skill.Id));
        }
Ejemplo n.º 7
0
        public async Task <Contact> createContactAsync(Contact contact)
        {
            Contact contactFromRepository = await retrieveContactAsync(contact.Id);

            if (contactFromRepository != null)
            {
                throw new BusinnessDomainException($"The contact {contact.Id} already exists");
            }

            FakeDataBase.getInstance().Contacts.Add(
                new Contact
            {
                Id        = contact.Id,
                FirstName = contact?.FirstName,
                LastName  = contact?.LastName,
                Address   = contact?.Address,
                Email     = contact?.Email
            }
                );

            return(await retrieveContactAsync(contact.Id));
        }
Ejemplo n.º 8
0
        public Contact removeSkillFromContact(int skillId, int contactId)
        {
            Skill skill = FakeDataBase.getInstance().Skills.FirstOrDefault <Skill>(s => s.Id == skillId);

            if (skill == null)
            {
                throw new BusinnessDomainException($"The skill {skillId} does not exist");
            }

            Contact contact = FakeDataBase.getInstance().Contacts.FirstOrDefault <Contact>(c => c.Id == contactId);

            if (contact == null)
            {
                throw new BusinnessDomainException($"The contact {contactId} does not exist");
            }

            if (contact.Skills.Contains(skill))
            {
                contact.Skills.Remove(skill);
            }

            return(contact);
        }
Ejemplo n.º 9
0
 public async Task <long> longCountAsync() => await FakeDataBase.getInstance().Contacts.ToAsyncEnumerable <Contact>().LongCount <Contact>();
Ejemplo n.º 10
0
 public async Task <Contact> retrieveContactAsync(int id) => await FakeDataBase.getInstance().Contacts.ToAsyncEnumerable().SingleOrDefault(m => m.Id == id);
Ejemplo n.º 11
0
 public Task <IEnumerable <Contact> > retrieveAllContactsAsync() => Task <long> .Run(() => FakeDataBase.getInstance().Contacts.AsEnumerable <Contact>());
Ejemplo n.º 12
0
 public async Task <Skill> retrieveSkillAsync(int id) => await FakeDataBase.getInstance().Skills.ToAsyncEnumerable().SingleOrDefault(m => m.Id == id);
Ejemplo n.º 13
0
 public async Task <long> longCountAsync() => await FakeDataBase.getInstance().Skills.ToAsyncEnumerable <Skill>().LongCount <Skill>();
Ejemplo n.º 14
0
 public void CleanUp()
 {
     FakeDataBase.Reset();
 }
Ejemplo n.º 15
0
 public ValuesController(FakeDataBase dataBase)
 {
     _dataBase = dataBase;
 }
Ejemplo n.º 16
0
 public DataRepository(FakeDataBase fakeContext)
     : base()
 {
     this.fakeContext = fakeContext;
 }
Ejemplo n.º 17
0
 static void Main(string[] args)
 {
     FakeDataBase.addMusics();
     Introduction.Showmenu();
 }
Ejemplo n.º 18
0
 public PetRepository()
 {
     FakeDataBase.InitData();
 }
Ejemplo n.º 19
0
 public Task <IEnumerable <Skill> > retrieveAllSkillsAsync() => Task <long> .Run(() => FakeDataBase.getInstance().Skills.AsEnumerable <Skill>());