Skip to content

Instantly share code, notes, and snippets.

View efeozyer's full-sized avatar
🧠
feed your brain!

Efe ÖZYER efeozyer

🧠
feed your brain!
View GitHub Profile
@efeozyer
efeozyer / Script.ps1
Created June 6, 2020 07:47
Powershell System Resources
$totalRam = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).Sum
while($true) {
$date = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$cpuTime = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue
$availMem = (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue
$date + ' > CPU: ' + $cpuTime.ToString("#,0.000") + '%, Avail. Mem.: ' + $availMem.ToString("N0") + 'MB (' + (104857600 * $availMem / $totalRam).ToString("#,0.0") + '%)'
Start-Sleep -s 2
}
[TestFixture]
public class ProductRepositoryFixture
{
public ProductRepositoryFixture()
{
var builder = new SqlConnectionStringBuilder("Database connection string here!");
var dbContext = new DbContext(builder.ToString());
_prdocutRepository = new ProductRepository(dbContext);
}
public class ProductController
{
public ProductController(IProductRepository productRepository)
{
_productRepository = productRepository;
}
[HttPost]
public ActionResult Create([FromBody] Product model)
{
public class ProductRepository : IProductRepository
{
public ProductRepository(DbContext dbContenxt) {
_table = dbContext.Set<Product>();
_dbContext = dbContext;
}
public bool Create(Product product) {
_table.Add(product);
return Save();
public class IProductRepository {
bool Create(Product product);
bool Delete(int productId);
IEnumerable<Product> GetAll();
void DeleteAll();
}
public class ProductController
{
[HttPost]
public ActionResult Create([FromBody] Product model)
{
using(var dbContext = new ProductContext())
{
dbContext.Products.Add(model);
dbContext.SaveChanges();
}
void Should_Insert_Entity()
{
// Arrange
var entity = new Account
{
Id = "1",
Name = "first_Account",
IsActive = true,
CreatedOn = DateTime.UtcNow
};