tdd

Get Stored Procedure from Data Context : Linq to SQl

孤街浪徒 提交于 2020-01-10 05:24:02
问题 I have a stored procedure named ParseXML in SQL Server. I have a repository pattern using LINQ to SQL. I need to call the stored procedure from within the repository layer. Unlike GetTable method, we don’t have a GetStoredProcedure method for data context. How can we call the stored procedure in such a scenario? Dbml Code [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.ParseXML")] public ISingleResult<ParseXMLResult> ParseXML([global::System.Data.Linq.Mapping.ParameterAttribute

Using TDD to drive out thread-safe code

跟風遠走 提交于 2020-01-09 13:08:58
问题 What's a good way to leverage TDD to drive out thread-safe code? For example, say I have a factory method that utilizes lazy initialization to create only one instance of a class, and return it thereafter: private TextLineEncoder textLineEncoder; ... public ProtocolEncoder getEncoder() throws Exception { if(textLineEncoder == null) textLineEncoder = new TextLineEncoder(); return textLineEncoder; } Now, I want to write a test in good TDD fashion that forces me to make this code thread-safe.

Using TDD to drive out thread-safe code

a 夏天 提交于 2020-01-09 13:07:06
问题 What's a good way to leverage TDD to drive out thread-safe code? For example, say I have a factory method that utilizes lazy initialization to create only one instance of a class, and return it thereafter: private TextLineEncoder textLineEncoder; ... public ProtocolEncoder getEncoder() throws Exception { if(textLineEncoder == null) textLineEncoder = new TextLineEncoder(); return textLineEncoder; } Now, I want to write a test in good TDD fashion that forces me to make this code thread-safe.

require cannot load such file

a 夏天 提交于 2020-01-06 14:16:23
问题 I have the following 2 files in the same dir: churn.rb: subsystem_names = ['audit', 'fulfillment', 'persistence', 'ui', 'util', 'inventory'] start_date = month_before(Time.now) puts header(start_date) subsystem_names.each do | name | puts subsystem_line(name, change_count_for(name)) end churn_test.rb: require "test/unit" require "churn" class ChurnTests < Test::Unit::TestCase def test_month_before_is_28_days assert_equal(Time.local(2005, 1, 1), month_before(Time.local(2005, 1, 29))) end end

Rspec not logging me in

扶醉桌前 提交于 2020-01-06 14:13:09
问题 I was looking at this answer to see how to test a session controller and wrote something like this: require 'spec_helper' describe SessionsController do context "We should login to the system and create a session" do let :credentials do {:user_name => "MyString", :password => "someSimpleP{ass}"} end let :user do FactoryGirl.create(:user, credentials) end before :each do post :create , credentials end it "should create a session" do puts user.inspect puts session[:user_id] #session[:user_id]

Rspec not logging me in

╄→尐↘猪︶ㄣ 提交于 2020-01-06 14:12:08
问题 I was looking at this answer to see how to test a session controller and wrote something like this: require 'spec_helper' describe SessionsController do context "We should login to the system and create a session" do let :credentials do {:user_name => "MyString", :password => "someSimpleP{ass}"} end let :user do FactoryGirl.create(:user, credentials) end before :each do post :create , credentials end it "should create a session" do puts user.inspect puts session[:user_id] #session[:user_id]

Using MozMill for testing standalone XUL applications

六眼飞鱼酱① 提交于 2020-01-06 08:28:46
问题 As a follow-up of this question, I am trying MozMill for testing standalone XUL applications (not a firefox extension). However, I did not "get it" yet - more specifically, how to test a XULRunner-based application. Consider this app, for example. For now, I can run it from command line, more or less this way: $ /path/to/xulrunner /full/path/to/mozmillexample/application.ini I would like to write Mozmill scripts to test it. For example, I would like to write a test such as this one, which has

Unit testing RxJava in MVP presenter in android

落爺英雄遲暮 提交于 2020-01-06 07:15:15
问题 I am new to TDD. Also new to MVP and Rxjava. I just dive into it and It is worth it. But I stuck at the testing part. I understand the basis of unit testing. It is a little bit difficult for me in beginning. But I stuck here and So how can test the presenter? Here is the Presenter class - public class NewsPresenter { private final RxjavaService service; private final MainView view; private CompositeSubscription subscriptions; public NewsPresenter(RxjavaService service, MainView view) { this

Unit testing RxJava in MVP presenter in android

吃可爱长大的小学妹 提交于 2020-01-06 07:15:10
问题 I am new to TDD. Also new to MVP and Rxjava. I just dive into it and It is worth it. But I stuck at the testing part. I understand the basis of unit testing. It is a little bit difficult for me in beginning. But I stuck here and So how can test the presenter? Here is the Presenter class - public class NewsPresenter { private final RxjavaService service; private final MainView view; private CompositeSubscription subscriptions; public NewsPresenter(RxjavaService service, MainView view) { this

Python pytest: capturing stdout always fails

折月煮酒 提交于 2020-01-06 05:45:26
问题 I'm trying to capture output from stdout / print statements in pytest (Python version 3.6). This always fails: message = 'The meaning of life is not actually 42\n' def print_greeting(): """print 42 to stdout""" # write to stdout sys.stdout.write(message) # this fails # print to stdout print('Message again: ', message) # this fails too def test_printgreeting(capsys): """assert '42' was printed to stdout""" # capture stdout / stderr out, err = capsys.readouterr() print_greeting() # 42 should be