Niso
New member
- Joined
- Nov 30, 2020
- Messages
- 3
- Programming Experience
- 1-3
hello,
im having trouble connecting my DB to the unit testing. i saw a video on youtube that recommended moq and adding repositorys, but i dont think im suppose to get that far.
i just want to write some simple tests to see if they are added to the db as expected.
im adding the code for my controller and the testing unit. i know the code is not fully implemented but i was just trying to see if i can reach the DB through the test project (i was just trying to reach)
the unit test project with the error:
i cant understand what the problem is and would love an explanation on how to make it work.
please help!!
im having trouble connecting my DB to the unit testing. i saw a video on youtube that recommended moq and adding repositorys, but i dont think im suppose to get that far.
i just want to write some simple tests to see if they are added to the db as expected.
im adding the code for my controller and the testing unit. i know the code is not fully implemented but i was just trying to see if i can reach the DB through the test project (i was just trying to reach)
C#:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using VolunteesMVC6.Models;
namespace VolunteesMVC6.Controllers
{
public class HomeController : Controller
{
string xml = @"C:\Users\nisan\Desktop\Niso\תכנות\VolunteesMVC6\VolunteesMVC6\obj\Debug\cities.xml";
public ActionResult Index()
{
ds.ReadXml(xml);
return View();
}
public ActionResult SignUp()
{
//a veriable class that EF created from SQL
tb_Users users = new tb_Users();
if (ds.Tables.Count==0)
{
ds.ReadXml(xml);
}
string[] names=GetAllCities();
Array.Sort(names);
ViewBag.CitiesList = new SelectList(names);
return View(users);
}
DataSet ds = new DataSet();
public string[] GetAllCities()
{
return (from row in ds.Tables[0].AsEnumerable()
select row.Field<string>("strCity")).ToArray();
}
}
}
the unit test project with the error:
i cant understand what the problem is and would love an explanation on how to make it work.
please help!!